chksum←{⎕IO ⎕ML←0 1 ⍝ Simple ⍺-digit checksum. bvec←{ ⍝ byte-vector. sub←{(⍴⍵)bvec,⍵} ⍝ bvec of sub-item. 0∊⍴⍵:⍺ pref sub⊃⍵ ⍝ null: prototypical item. (⍺≡⍬)∧isref⊃⍵:⍬ ⍝ ref: ignored. ⍵≡,⎕NULL:⍬ ⍝ ⎕null: ignored. 6=10|⎕DR ⍵:⍺ pref↑,/sub¨⍵ ⍝ nested: cat of sub-vectors. 11=⎕DR ⍵:⍺ pref ⍵ ⍝ boolean: items of array. 2|⎕DR ⍵:⍺ pref bytes ⍵ ⍝ numeric: bytes of array. ⍺ pref bytes ⎕UCS ⍵ ⍝ character: unicode indices. } isref←{9=⎕NC'⍵'} ⍝ namespace reference. bytes←{256|83 ⎕DR ⍵} ⍝ data bytes. pref←{(bytes ⍺,¯1),⍵} ⍝ prefixed shape vector. wsum←{⍵+.×1+⍳⍴⍵} ⍝ weighted sum. ⍺←6 ⋄ (10*⍺)|wsum(⍴⍵)bvec,⍵ ⍝ ⍺-digit weighted sum of byte-vector. } code_colours test script Back to: notes Back to: Workspaces