code-arrays: don't ask, don't tell
parent
1eaea88912
commit
4dc12f1660
|
@ -0,0 +1 @@
|
|||
Doug Coleman
|
|
@ -0,0 +1,13 @@
|
|||
! Copyright (C) 2011 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: code-arrays locals math tools.test ;
|
||||
IN: code-arrays.tests
|
||||
|
||||
[ { 1 2 9 } ] [ {{ 1 2 3 sq }} ] unit-test
|
||||
[ { 1 2 { 9 } } ] [ {{ 1 2 {{ 3 sq }} }} ] unit-test
|
||||
|
||||
[ H{ { 9 3 } { 4 1 } } ] [ H{{ {{ 3 sq 3 }} {{ 2 sq 1 }} }} ] unit-test
|
||||
|
||||
:: local-code-arrays ( -- seq ) {{ 1 2 3 + }} ;
|
||||
|
||||
[ { 1 5 } ] [ local-code-arrays ] unit-test
|
|
@ -0,0 +1,25 @@
|
|||
! Copyright (C) 2011 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: combinators.smart hashtables kernel parser quotations
|
||||
sequences vectors ;
|
||||
IN: code-arrays
|
||||
|
||||
: parse-code-array ( delimiter quot stack -- seq )
|
||||
[ parse-until >quotation ] dip curry append! ;
|
||||
|
||||
DEFER: }}
|
||||
DEFER: ]]
|
||||
|
||||
SYNTAX: {{ \ }} [ output>array ] parse-code-array ;
|
||||
|
||||
SYNTAX: [[ \ ]] [ [ ] output>sequence ] parse-code-array ;
|
||||
|
||||
SYNTAX: H{{ \ }} [ output>array >hashtable ] parse-code-array ;
|
||||
|
||||
SYNTAX: V{{ \ }} [ V{ } output>sequence ] parse-code-array ;
|
||||
|
||||
: vector ( seq -- vector ) >vector ;
|
||||
|
||||
: hashtable ( seq -- hashtable ) >hashtable ;
|
||||
|
||||
: quotation ( seq -- vector ) >quotation ;
|
Loading…
Reference in New Issue