-USING: kernel parser namespaces quotations arrays vectors strings
- sequences assocs classes.tuple math combinators ;
+USING: kernel parser combinators sequences splitting quotations arrays macros
+ arrays.lib combinators.cleave combinators.conditional newfx ;
IN: bake
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-TUPLE: insert-quot expr ;
+SYMBOL: ,
+SYMBOL: @
-C: <insert-quot> insert-quot
-
-: ,[ \ ] [ >quotation <insert-quot> ] parse-literal ; parsing
+: comma? ( obj -- ? ) , = ;
+: atsym? ( obj -- ? ) @ = ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-TUPLE: splice-quot expr ;
-
-C: <splice-quot> splice-quot
+DEFER: [bake-array]
-: %[ \ ] [ >quotation <splice-quot> ] parse-literal ; parsing
+: broil-element ( obj -- quot )
+ {
+ { [ comma? ] [ drop [ >r ] ] }
+ { [ array? ] [ [bake-array] [ >r ] append ] }
+ { [ drop t ] [ [ >r ] prefix-on ] }
+ }
+ 1cond ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-: ,u ( seq -- seq ) unclip building get push ;
+: [broil] ( array -- quot )
+ [ reverse [ broil-element ] map concat ]
+ [ length [ drop [ r> ] ] map concat ]
+ [ length [ narray ] prefix-on ]
+ tri append append
+ >quotation ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-SYMBOL: exemplar
+: [simmer] ( array -- quot )
-: reset-building ( -- ) 1024 <vector> building set ;
+ { @ } split reverse
+ [ [ [bake-array] [ append ] append [ >r ] append ] map concat ]
+ [ length [ drop [ r> append ] ] map concat ]
+ bi
-: save-exemplar ( seq -- seq ) dup exemplar set ;
+ >r 2 head* [ >r ] append r> ! remove the last append
-: finish-baking ( -- seq ) building get exemplar get like ;
+ [ { } ] swap append
-DEFER: bake
+ append ;
-: bake-item ( item -- )
- { { [ dup \ , = ] [ drop , ] }
- { [ dup \ % = ] [ drop % ] }
- { [ dup \ ,u = ] [ drop ,u ] }
- { [ dup insert-quot? ] [ insert-quot-expr call , ] }
- { [ dup splice-quot? ] [ splice-quot-expr call % ] }
- { [ dup integer? ] [ , ] }
- { [ dup string? ] [ , ] }
- { [ dup tuple? ] [ tuple>array bake >tuple , ] }
- { [ dup assoc? ] [ [ >alist bake ] keep assoc-like , ] }
- { [ dup sequence? ] [ bake , ] }
- { [ t ] [ , ] } }
- cond ;
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-: bake-items ( seq -- ) [ bake-item ] each ;
+: [bake-array] ( array -- quot ) [ @ member? ] [ [simmer] ] [ [broil] ] 1if ;
-: bake ( seq -- seq )
- [ reset-building save-exemplar bake-items finish-baking ] with-scope ;
+MACRO: bake-array ( array -- quot ) [bake-array] ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-: `{ \ } [ >array ] parse-literal \ bake parsed ; parsing
-
+: `{ \ } [ >array ] parse-literal \ bake-array parsed ; parsing
\ No newline at end of file
USING: kernel debugger system namespaces sequences splitting combinators
io io.files io.launcher prettyprint bootstrap.image
- bake combinators.cleave
+ combinators.cleave
builder.util
builder.common
builder.release.branch
combinators sequences splitting quotations arrays strings tools.time
sequences.deep accessors assocs.lib
io.encodings.utf8
- combinators.cleave bake calendar calendar.format ;
+ combinators.cleave calendar calendar.format ;
IN: builder.util
--- /dev/null
+
+USING: kernel combinators sequences macros fry newfx combinators.cleave ;
+
+IN: combinators.conditional
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+MACRO: 1if ( test then else -- ) '[ dup @ , , if ] ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+MACRO: 1cond ( tbl -- )
+ [ [ 1st [ dup ] prepend ] [ 2nd ] bi {2} ] map
+ [ cond ] prefix-on ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
[ t ] [
"m" get next-change drop
- [ "." = ] [ "monitor-test-self" temp-file = ] bi or
+ [ "" = ] [ "monitor-test-self" temp-file = ] bi or
] unit-test
[ ] [ "m" get dispose ] unit-test
: adjoin ( seq elt -- seq ) over sets:adjoin ;
: adjoin-on ( elt seq -- seq ) tuck sets:adjoin ;
: adjoined ( set elt -- ) swap sets:adjoin ;
-: adjoined-on ( elt set -- ) sets:adjoin ;
\ No newline at end of file
+: adjoined-on ( elt set -- ) sets:adjoin ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: start ( seq subseq -- i ) swap sequences:start ;
\ No newline at end of file
USING: kernel namespaces arrays quotations sequences assocs combinators
- mirrors math math.vectors random macros bake ;
+ mirrors math math.vectors random macros fry ;
IN: random-weighted
dup [ second ] map swap [ first ] map random-weighted swap nth ;
MACRO: call-random-weighted ( exp -- )
- [ keys ] [ values <enum> >alist ] bi swap
- [ , random-weighted , case ] bake ;
+ [ keys ] [ values <enum> >alist ] bi
+ '[ , random-weighted , case ] ;
-USING: kernel parser namespaces threads arrays sequences unix unix.process bake ;
+USING: kernel parser namespaces threads arrays sequences unix unix.process
+ bake ;
IN: raptor
\ set-parameters [ [set-parameters] ] 1 define-transform
-: parametric-quot ( parameters quot -- quot )
-[ [ swap ] set-parameters [ ] call ] make* ;
+! : parametric-quot ( parameters quot -- quot )
+! [ [ swap ] set-parameters [ ] call ] make* ;
+
+: parametric-quot ( parameters quot -- quot ) '[ , set-parameters , call ] ;
+
: scoped-quot ( quot -- quot ) [ with-scope ] curry ;
VAR: headers
: include-headers ( -- seq )
- headers> [ { "#include <" , ">" } bake to-string ] map ;
+ headers> [ `{ "#include <" , ">" } to-string ] map ;
: size-of-c-program ( type -- lines )
- {
+ `{
"#include <stdio.h>"
include-headers
{ "main() { printf( \"%i\" , sizeof( " , " ) ) ; }" }
}
- bake to-strings ;
+ to-strings ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
USING: kernel namespaces arrays sequences threads math math.vectors
- ui random bake springies springies.ui ;
+ ui random springies springies.ui ;
IN: springies.models.2x2snake
-USING: kernel namespaces arrays sequences threads math ui random bake
+USING: kernel namespaces arrays sequences threads math ui random fry
springies springies.ui ;
IN: springies.models.3snake
;
-: go* ( quot -- )
- [ [ [ springies-window* 1000 sleep % ] with-scope ] with-ui ] bake call ;
+! : go* ( quot -- )
+! [ [ [ springies-window* 1000 sleep % ] with-scope ] with-ui ] bake call ;
+
+: go* ( quot -- ) '[ [ springies-window* 1000 sleep @ ] with-scope ] with-ui ;
! : go ( -- ) [ [ springies-window* 1000 sleep model ] with-scope ] with-ui ;
-USING: kernel namespaces arrays sequences threads math ui random bake
+USING: kernel namespaces arrays sequences threads math ui random
springies springies.ui ;
IN: springies.models.belt-tire
USING: kernel namespaces arrays sequences threads math math.vectors
- ui random bake springies springies.ui ;
+ ui random springies springies.ui ;
IN: springies.models.nifty
USING: kernel namespaces arrays sequences threads math math.vectors
- ui random bake
+ ui random
springies springies.ui ;
IN: springies.models.urchin
USING: kernel namespaces threads sequences math math.vectors
opengl.gl opengl colors ui ui.gadgets ui.gadgets.slate
- bake rewrite-closures vars springies ;
+ fry rewrite-closures vars springies ;
IN: springies.ui
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-: go* ( quot -- )
- [ [ [ springies-window* 1000 sleep % ] with-scope ] with-ui ] bake call ;
+: go* ( quot -- ) '[ [ springies-window* 1000 sleep @ ] with-scope ] with-ui ;
\ No newline at end of file