LINUX.ORG.RU

История изменений

Исправление loz, (текущая версия) :

Например вот так можно добавить «без пробельную» арифметику:

>> 123+5*6
*** Syntax Error: invalid integer! at "123+5*6"
*** Where: do
*** Stack: load 
>> nums: charset [#"0" - #"9"]
== make bitset! #{000000000000FFC0}
>> ops: ["+" keep ('+) | "-" keep ('-) | "*" keep ('*) | "/" keep ('/) ]
== ["+" keep ('+) | "-" keep ('-) | "*" keep ('*) | "/" keep ('/)]
>> math: [ collect any [ ops | copy n some nums keep (to-integer n) ] ]
== [collect any [ops | copy n some nums keep (to-integer n)]]
>> parse "123+5*6" math
== [123 + 5 * 6]
>> do parse "123+5*6" math
== 768

Исходная версия loz, :

Например вот так можно добавить «без пробельную»:

>> 123+5*6
*** Syntax Error: invalid integer! at "123+5*6"
*** Where: do
*** Stack: load 
>> nums: charset [#"0" - #"9"]
== make bitset! #{000000000000FFC0}
>> ops: ["+" keep ('+) | "-" keep ('-) | "*" keep ('*) | "/" keep ('/) ]
== ["+" keep ('+) | "-" keep ('-) | "*" keep ('*) | "/" keep ('/)]
>> math: [ collect any [ ops | copy n some nums keep (to-integer n) ] ]
== [collect any [ops | copy n some nums keep (to-integer n)]]
>> parse "123+5*6" math
== [123 + 5 * 6]
>> do parse "123+5*6" math
== 768