Apl2ToDo/ConversionAlgorithms

This is a sub-page of PhraseBook/ToDo/Apl2Idioms

CA←'FDCBA'[+/IA∘.≥10×6 7 8 9] ⍝ Students grades given score IA.

CA←'FDCBA'[+/IA∘.≥10×0 6 7 8 9] ⍝ Students grades given score IA.

I←+/Iׯ1*I<1⌽I←0,(,(10*⍳4)∘.×1 5)['IVXLCDM'⍳C] ⍝ Roman numerals to Arabic.

I←+/Iׯ1*I<1⌽I←0,(,(1,10*⍳3)∘.×1 5)['IVXLCDM'⍳C]⍝ Roman numerals to Arabic.

IA←(¯1⌽⍳1+⍴⍴NA)⍉((1+⌊IS⍟1⌈⌈/,NA)⍴IS)⊤NA ⍝ Base IS representation of a number.

IA←(¯1⌽⍳1+⍴⍴NA)⍉((1+⌊10⍟1⌈⌈/,NA)⍴10)⊤NA ⍝ Base 10 representation of a number.

NA←(¯1⌽⍳1+⍴⍴FA)⍉⌊(IS⍴NS)⊤(NS*IS)×1|FA ⍝ IS place-base NS rep. of a fraction.

NA←⊃⍎¨⊂[¯1+⍴⍴CA]',',CA ⍝ Convert non-empty CA to NA - rank ≥1.

NA←⊃⍎¨⊂[⍴⍴CA]',',CA ⍝ Convert non-empty CA to NA - rank ≥1.

NM←⊃⍎¨⊂[1]',',CM ⍝ Convert non-empty CM to numeric vector.

NM←⊃⍎¨⊂[2]',',CM ⍝ Convert non-empty CM to numeric vector.

N←1↓⍎'0',',',CM ⍝ Convert character matrix to numeric vector.

I←1↓⍎'0 ',(Cε' 0123456789')/C ⍝ Convert to numeric, throw out characters.

I←10⊥'0123456789'⍳C ⍝ Convert character to numeric.

I←10⊥¯1+'0123456789'⍳C ⍝ Convert character to numeric.

I←10⊥⍉M ⍝ Convert rows of digits to base 10.

I←⍎¨C ⍝ Convert character vector to vector of digits.

BM←⍉((1+⌊2⍟1⌈⌈/I)⍴2)⊤I ⍝ Convert integer to binary.

IS←2⊥B ⍝ Convert binary to integer.

C←16 16⍴⎕AV ⍝ EBCDIC/ASCII sequence in HEX table.

M←(256⊥1↓[0]N)×(×128-M)×16*¯63⌈¯70+128|M←1↑[0]N ⍝ Convert halfword to float.

M←(256⊥1↓[1]N)×(×128-M)×16*¯63⌈¯70+128|M←1↑[1]N ⍝ Convert halfword to float.


CategoryPhrasebookToDo

apl2todo/conversionalgorithms (last edited 2011-04-25 12:33:19 by KaiJaeger)