From 7ceeb20b0aebe0eac8aeb9140f491973756c32bd Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 4 Oct 2015 21:01:12 +0200 Subject: Numbers and strings to rip code, on stdout and in memory! --- ex/numfmt.rip | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ex/str2rip.rip | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 ex/numfmt.rip create mode 100644 ex/str2rip.rip diff --git a/ex/numfmt.rip b/ex/numfmt.rip new file mode 100644 index 0000000..903c183 --- /dev/null +++ b/ex/numfmt.rip @@ -0,0 +1,72 @@ +F[D0GW[SodD0G]P] + +0I[ + F[ + 0I[[value]] + D9i9aGI[ 0I[{if value>19}] + D9iqD3r9ims 0I[[quotient modulus]] + S 0I[[modulus quotient]] + 0I[[modulus "quotient" ]] + 455mm5aD4aS87mi 0I[[modulus "quotient" 'm' 'i' '9']] + 4R 3a D 0I[[modulus "quotient" 'm' 'i' '9' ]] + 5R S 0I[[modulus "quotient" 'i' '9' 'm' ]] + i 0I[[modulus "quotient" 'i' '9' 'm' ]] + r 0I[[modulus 'm' "quotient" 'i' '9' ] + [modulus 'm' "quotient" 'i' '9' ]] + DiiR 0I[['m' "quotient" 'i' '9' modulus]] + D1GI[ 0I[{if modulus>1}] + 0I[['m' "quotient" 'i' '9' "modulus" ]] + DiiR 0I[['m' "quotient" 'i' '9' "modulus" ]] + a 0I[['m' "quotient" 'i' '9' "modulus" ]] + 99im7a S i 0I[['m' "quotient" 'i' '9' "modulus" 'a' ]] + D3r i 0I[['m' "quotient" 'i' '9' "modulus" 'a' ]] + r 0I[['a' 'm' "quotient" 'i' '9' "modulus" ] + ['a' 'm' "quotient" 'i' '9' "modulus" ]] + 0d 0I[['a' 'm' "quotient" 'i' '9' "modulus" -1]] + ] + D0GI[ 0I[{if modulus>0, so =1}] + P 9iDm5a S i 0I[['m' "quotient" 'i' '9' 'i' ]] + Di 0I[['m' "quotient" 'i' '9' 'i' ]] + 3RS 0I[['m' "quotient" 'i' '9' 'i' ]] + r 0I[['i' 'm' "quotient" 'i' '9' ] + ['i' 'm' "quotient" 'i' '9' ]] + 0d 0I[['i' 'm' "quotient" 'i' '9' -1]] + ] + P0d 0I[["..." -1]] + ] + D9GI[ 0I[{if value>9, so 10..19}] + 455mm5a87mi 2 0I[[value 'i' '9' 2]] + 4R 0I[['i' '9' 2 value]] + D92aGI[ 0I[{if value>11, so 12..19}] + SP 0I[['i' '9' value]] + 9is 0I[['i' '9' value-10]] + 68ma 0I[['i' '9' 'value-10']] + 99im7a 0I[['i' '9' 'value-10' 'a']] + 4r 4 0I[['a' 'i' '9' 'value-10' 4]] + 0d 0I[['a' 'i' '9' 'value-10' 4 -1]] + ] + D9iGI[ 0I[{if value>10, so =11}] + PP 0I[['i' '9']] + SD3R 0I[['i' 'i' '9']] + 3 0d 0I[['i' 'i' '9' 3 -1]] + ] + P0d 0I[["..." -1]] + ] + D0dGI[ 0I[{if value>-1, so 0..9}] + 86ma 1 0I[['value' 1]] + 0d 0I[['value' 1 -1]] + ] + P + ] +] + + +F[D9i9aGI[D9iqD3r9imsS455mm5aD4aS87mi4R3aD5RSirDiiRD1GI[DiiRa99im7aSiD3rir0d]D0GI[P9iDm5aSiDi3RSr0d]P0d]D9GI[455mm5a87mi24RD92aGI[SP9is68ma99im7a4r40d]D9iGI[PPSD3R30d]P0d]D0dGI[86ma10d]P] + + +0 +1W[ + DO 84mo D9io + i +D9iDm2mL] +P diff --git a/ex/str2rip.rip b/ex/str2rip.rip new file mode 100644 index 0000000..1b5b369 --- /dev/null +++ b/ex/str2rip.rip @@ -0,0 +1,70 @@ +0I[ + F[ + 0I[[value]] + D9i9aGI[ 0I[{if value>19}] + D9iqD3r9ims 0I[[quotient modulus]] + S 0I[[modulus quotient]] + 0I[[modulus] -> "quotient"] + + 455mm5aD4aS87mi 0I[[modulus 'm' 'i' '9']] + ooo 0I[[modulus] -> "9im"] + D1GI[ 0I[{if modulus>1}] + 0I[[] -> "modulus"] + 99im7ao 0I[[] -> 'a'] + 0d 0I[[-1]] + ] + D0GI[ 0I[{if modulus>0, so =1}] + 9iDm5ao 0I[[modulus] -> 'i'] + ] + P0d 0I[[-1]] + ] + D9GI[ 0I[{if value>9, so 10..19}] + 455mm5a87mi 0I[[value 'i' '9']] + oo 0I[[value] -> "9i"] + D92aGI[ 0I[{if value>11, so 12..19}] + 9isD 0I[[value] -> repr(value-10)] + 99im7ao 0I[[value] -> 'a'] + ] + D9iGI[ 0I[{if value>10, so =11}] + 9iDm5ao 0I[[value] -> 'i'] + ] + P0d 0I[[-1]] + ] + D0dGI[ 0I[{if value>-1, so 0..9}] + 86mao 0I[[] -> value] + 0d 0I[[-1]] + ] + P + ] +] + + +F[D9i9aGI[D9iqD3r9imsS455mm5aD4aS87mioooD1GI[99im7ao0d]D0GI[9iDm5ao]P0d]D9GI[455mm5a87miooD92aGI[9isD99im7ao]D9iGI[9iDm5ao]P0d]D0dGI[86mao0d]P] + + + +0 + +86mo + +gD0dEnW[ + + SD3rs + + D0GI[ + D + 99im7ao + a + 1 + ] + D0LI[ + 0Ss + D + 278mm3ao + s + 1 + ] + P + 88m4ao + 278mmdo +gD0dEn] -- cgit v1.2.3-70-g09d2