brainfuck: collapse spaces to compress better, 2+2=5 test.
parent
2f53a7c5de
commit
125f64a72f
|
|
@ -60,4 +60,16 @@ IN: brainfuck.tests
|
|||
[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-]"""
|
||||
get-brainfuck ] unit-test
|
||||
|
||||
! fun with numbers: 2 + 2 = 5
|
||||
|
||||
{ "5" } [
|
||||
"""
|
||||
+++++ +++++
|
||||
+ +
|
||||
+ + + +++++
|
||||
+++++ +++ +++++
|
||||
+ + + +++++
|
||||
+ +
|
||||
+++++ +++++.
|
||||
""" get-brainfuck
|
||||
] unit-test
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2009 John Benediktsson
|
||||
! See http://factorcode.org/license.txt for BSD license
|
||||
|
||||
USING: accessors assocs io io.streams.string kernel macros
|
||||
math peg.ebnf prettyprint sequences strings ;
|
||||
USING: accessors ascii assocs fry io io.streams.string kernel
|
||||
macros math peg.ebnf prettyprint sequences strings ;
|
||||
|
||||
IN: brainfuck
|
||||
|
||||
|
|
@ -70,8 +70,8 @@ code = (loop|ops|unknown)* => [[ compose-all ]]
|
|||
PRIVATE>
|
||||
|
||||
MACRO: run-brainfuck ( code -- )
|
||||
[ <brainfuck> ] swap parse-brainfuck [ drop flush ] 3append ;
|
||||
[ blank? not ] filter parse-brainfuck
|
||||
'[ <brainfuck> @ drop flush ] ;
|
||||
|
||||
: get-brainfuck ( code -- result )
|
||||
[ run-brainfuck ] with-string-writer ; inline
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue