]> gitweb.factorcode.org Git - factor.git/commitdiff
kernel: new combinator 2with = with with
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 22 Jul 2014 13:09:26 +0000 (15:09 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 22 Jul 2014 14:40:13 +0000 (07:40 -0700)
38 files changed:
basis/combinators/short-circuit/short-circuit.factor
basis/compiler/cfg/branch-splitting/branch-splitting.factor
basis/compiler/cfg/def-use/def-use.factor
basis/compiler/cfg/linear-scan/live-intervals/live-intervals.factor
basis/db/tuples/tuples.factor
basis/debugger/debugger-docs.factor
basis/game/input/input.factor
basis/io/monitors/recursive/recursive.factor
basis/math/functions/functions.factor
basis/math/vectors/simd/intrinsics/intrinsics.factor
basis/sorting/insertion/insertion.factor
basis/sorting/slots/slots.factor
basis/typed/typed.factor
basis/ui/gadgets/menus/menus.factor
basis/unicode/collation/collation-tests.factor
basis/unicode/collation/collation.factor
basis/vocabs/metadata/resources/resources.factor
core/generic/math/math.factor
core/generic/single/single.factor
core/kernel/kernel-docs.factor
core/kernel/kernel-tests.factor
core/kernel/kernel.factor
extra/benchmark/raytracer-simd/raytracer-simd.factor
extra/benchmark/yuv-to-rgb/yuv-to-rgb.factor
extra/boids/simulation/simulation.factor
extra/bunny/model/model.factor
extra/game/models/collada/collada.factor
extra/gml/viewer/viewer.factor
extra/graphviz/notation/notation.factor
extra/irc/client/participants/participants.factor
extra/koszul/koszul.factor
extra/nurbs/nurbs.factor
extra/pcre/pcre.factor
extra/project-euler/265/265.factor
extra/sudoku/sudoku.factor
extra/usa-cities/usa-cities.factor
extra/window-controls-demo/window-controls-demo.factor
extra/yaml/yaml.factor

index f775c2f24cb33a636c1908cdc5dfbe09f32de65b..9e59d5ee9e07ae63ad72355e6caf1fff55318e0c 100644 (file)
@@ -29,8 +29,8 @@ PRIVATE>
 
 : 0&& ( quots -- ? ) [ ] unoptimized-&& ;
 : 1&& ( obj quots -- ? ) [ with ] unoptimized-&& ;
-: 2&& ( obj1 obj2 quots -- ? ) [ with with ] unoptimized-&& ;
-: 3&& ( obj1 obj2 obj3 quots -- ? ) [ with with with ] unoptimized-&& ;
+: 2&& ( obj1 obj2 quots -- ? ) [ 2with ] unoptimized-&& ;
+: 3&& ( obj1 obj2 obj3 quots -- ? ) [ 3 nwith ] unoptimized-&& ;
 
 MACRO: n|| ( quots n -- quot )
     [
@@ -51,5 +51,5 @@ PRIVATE>
 
 : 0|| ( quots -- ? ) [ ] unoptimized-|| ;
 : 1|| ( obj quots -- ? ) [ with ] unoptimized-|| ;
-: 2|| ( obj1 obj2 quots -- ? ) [ with with ] unoptimized-|| ;
-: 3|| ( obj1 obj2 obj3 quots -- ? ) [ with with with ] unoptimized-|| ;
+: 2|| ( obj1 obj2 quots -- ? ) [ 2with ] unoptimized-|| ;
+: 3|| ( obj1 obj2 obj3 quots -- ? ) [ 3 nwith ] unoptimized-|| ;
index 0222df9ad07f159124b2aa14efdb643f259bb321..157fd355cd3c363bee1f2057342a942981d3eb47 100644 (file)
@@ -44,7 +44,7 @@ IN: compiler.cfg.branch-splitting
 
 : update-successor-predecessors ( copies old-bb -- )
     dup successors>>
-    [ update-successor-predecessor ] with with each ;
+    [ update-successor-predecessor ] 2with each ;
 
 : split-branch ( bb -- )
     [ new-blocks ] keep
index 36e6bdd46ee838d21b7820dccd63706b81fa154a..9f750f16dc814c87970093d5e4565a3806e4fc24 100644 (file)
@@ -109,7 +109,7 @@ SYMBOLS: defs insns ;
 : insn-of ( vreg -- insn ) insns get at ;
 
 : set-def-of ( obj insn assoc -- )
-    swap defs-vregs [ swap set-at ] with with each ;
+    swap defs-vregs [ swap set-at ] 2with each ;
 
 : compute-defs ( cfg -- )
     H{ } clone [
index 5a9da37d03797d10145eeb6f4373edc16e6314e2..ad4ab4fe16390ae26fa027b3f40a1acd3e84058a 100644 (file)
@@ -162,7 +162,7 @@ M: hairy-clobber-insn compute-live-intervals* ( insn -- )
 : handle-live-out ( bb -- )
     live-out dup assoc-empty? [ drop ] [
         [ from get to get ] dip keys
-        [ live-interval add-range ] with with each
+        [ live-interval add-range ] 2with each
     ] if ;
 
 ! A location where all registers have to be spilled
index fcb7df53cc0f08cceabe73f260640fc758f28ce1..0bdb2978ee1580285be2f91ad2d8b0757595aa62 100644 (file)
@@ -35,9 +35,9 @@ GENERIC: eval-generator ( singleton -- object )
 
 : query-tuples ( exemplar-tuple statement -- seq )
     [ out-params>> ] keep query-results [
-        [ sql-row-typed swap resulting-tuple ] with with query-map
+        [ sql-row-typed swap resulting-tuple ] 2with query-map
     ] with-disposal ;
+
 : query-modify-tuple ( tuple statement -- )
     [ query-results [ sql-row-typed ] with-disposal ] keep
     out-params>> rot [
index a1bfdcc9c6ab7eeec4e4f2cde3a9e3a61fbbb731..e673fb0b2f1fa86f5b282fb44485f4c9e7f9daad 100644 (file)
@@ -105,7 +105,7 @@ HELP: type-check-error.
 { $error-description "Thrown by various primitives if one of the inputs does not have the expected type. Generic words throw " { $link no-method } " and " { $link no-math-method } " errors in such cases instead." } ;
 
 HELP: divide-by-zero-error.
-{ $error-description "This error is thrown when " { $link / } " or " { $link /i } " is called with with a zero denominator." }
+{ $error-description "This error is thrown when " { $link / } " or " { $link /i } " is called with a zero denominator." }
 { $see-also "division-by-zero" } ;
 
 HELP: signal-error.
index edd30b89faed606e1569d03539936761a26f97df..51e1b84ec9a5dedb46059628c17fb48109c8ed97 100644 (file)
@@ -45,7 +45,7 @@ ERROR: game-input-not-open ;
 
 : open-game-input ( -- )
     game-input-opened? [
-        (open-game-input) 
+        (open-game-input)
     ] unless
     game-input-opened [ 1 + ] change-global
     reset-mouse ;
@@ -55,7 +55,7 @@ ERROR: game-input-not-open ;
         1 -
     ] change-global
     game-input-opened? [
-        (close-game-input) 
+        (close-game-input)
         reset-game-input
     ] unless ;
 
@@ -79,7 +79,7 @@ SYMBOLS:
     get-controllers [
         [ product-id  = ]
         [ instance-id = ] bi-curry bi* and
-    ] with with find nip ;
+    ] 2with find nip ;
 
 TUPLE: keyboard-state keys ;
 
index 39701fef0174725fbcee883a3c9a37e08826f4cf..b0c86a215f76aa016ac48695a51aa6f467abfe25 100755 (executable)
@@ -69,7 +69,7 @@ M: recursive-monitor dispose*
             { +rename-file-new+ [ child-added ] }
             [ 3drop ]
         } case
-    ] with with each ;
+    ] 2with each ;
 
 : pump-loop ( -- )
     receive {
index 3ba6bfd3245fcd9b22e4e3012f642fd0f4d6a5a0..5dd3877e7d03d9a5c972b83932dddec601e6ed9a 100644 (file)
@@ -410,7 +410,7 @@ M: float round dup sgn 2 /f + truncate ;
 : roots ( x t -- seq )
     [ [ log ] [ recip ] bi* * e^ ]
     [ recip 2pi * 0 swap complex boa e^ ]
-    [ iota [ ^ * ] with with map ] tri ;
+    [ iota [ ^ * ] 2with map ] tri ;
 
 : sigmoid ( x -- y ) neg e^ 1 + recip ; inline
 
index 03529a0f363b2fd877c10c7dfb738d87f334518a..a784a77449ca8b88cb5b324d5123858147bde169 100644 (file)
@@ -160,7 +160,7 @@ PRIVATE>
 SIMD-INTRINSIC: (simd-v+)                ( a b rep -- c ) [ + ] components-2map ;
 SIMD-INTRINSIC: (simd-v-)                ( a b rep -- c ) [ - ] components-2map ;
 SIMD-INTRINSIC: (simd-vneg)              ( a   rep -- c ) [ neg ] components-map ;
-SIMD-INTRINSIC:: (simd-v+-)              ( a b rep -- c ) 
+SIMD-INTRINSIC:: (simd-v+-)              ( a b rep -- c )
     a b rep 2byte>rep-array :> ( a' b' )
     rep <rep-array> :> c'
     0  rep rep-length [ 1 -  2 <range> ] [ 2 /i ] bi [| n |
@@ -201,7 +201,7 @@ SIMD-INTRINSIC: (simd-vmax)              ( a b rep -- c ) [ max ] components-2ma
 ! XXX
 SIMD-INTRINSIC: (simd-v.)                ( a b rep -- n )
     [ 2byte>rep-array [ [ first ] bi@ * ] 2keep ] keep
-    1 swap rep-length [a,b) [ '[ _ swap nth-unsafe ] bi@ * + ] with with each ;
+    1 swap rep-length [a,b) [ '[ _ swap nth-unsafe ] bi@ * + ] 2with each ;
 SIMD-INTRINSIC: (simd-vsqrt)             ( a   rep -- c ) [ fsqrt ] components-map ;
 SIMD-INTRINSIC: (simd-vsad)              ( a b rep -- c ) 2byte>rep-array [ - abs ] [ + ] 2map-reduce ;
 SIMD-INTRINSIC: (simd-sum)               ( a   rep -- n ) [ + ] components-reduce ;
@@ -245,7 +245,7 @@ SIMD-INTRINSIC:: (simd-vmerge-tail)      ( a b rep -- c )
     ] unrolled-each-integer
     c' underlying>> ;
 SIMD-INTRINSIC: (simd-v<=)               ( a b rep -- c )
-    dup rep-tf-values '[ <= _ _ ? ] components-2map ; 
+    dup rep-tf-values '[ <= _ _ ? ] components-2map ;
 SIMD-INTRINSIC: (simd-v<)                ( a b rep -- c )
     dup rep-tf-values '[ <  _ _ ? ] components-2map ;
 SIMD-INTRINSIC: (simd-v=)                ( a b rep -- c )
@@ -276,14 +276,14 @@ SIMD-INTRINSIC: (simd-vpack-unsigned)    ( a b rep -- c )
     [ [ 2byte>rep-array cord-append ] [ rep-length 2 * ] bi ]
     [ narrow-vector-rep >uint-vector-rep [ <rep-array> ] [ rep-component-type ] bi ] bi
     '[ _ c:c-type-clamp ] swap unrolled-map-as-unsafe underlying>> ;
-SIMD-INTRINSIC: (simd-vunpack-head)      ( a   rep -- c ) 
+SIMD-INTRINSIC: (simd-vunpack-head)      ( a   rep -- c )
     [ byte>rep-array ] [ widen-vector-rep [ rep-length ] [ '[ _ >rep-array ] ] bi ] bi
     [ head-slice ] dip call( a' -- c' ) underlying>> ;
 SIMD-INTRINSIC: (simd-vunpack-tail)      ( a   rep -- c )
     [ byte>rep-array ] [ widen-vector-rep [ rep-length ] [ '[ _ >rep-array ] ] bi ] bi
     [ tail-slice ] dip call( a' -- c' ) underlying>> ;
 SIMD-INTRINSIC: (simd-with)              (   n rep -- v )
-    [ rep-length swap '[ _ ] ] [ <rep-array> ] bi replicate-as 
+    [ rep-length swap '[ _ ] ] [ <rep-array> ] bi replicate-as
     underlying>> ;
 SIMD-INTRINSIC: (simd-gather-2)          ( m n rep -- v ) <rep-array> [ 2 set-firstn-unsafe ] keep underlying>> ;
 SIMD-INTRINSIC: (simd-gather-4)          ( m n o p rep -- v ) <rep-array> [ 4 set-firstn-unsafe ] keep underlying>> ;
index d6681be8cc649a982738cfbaac5e16fada27b209..2a2ac4134a1e527d4892a26c0e22d790bdbf0266 100644 (file)
@@ -16,4 +16,4 @@ PRIVATE>
 
 : insertion-sort ( ... seq quot: ( ... elt -- ... elt' ) -- ... )
     ! quot is a transformation on elements
-    over length [ insert ] with with 1 -rot (each-integer) ; inline
+    over length [ insert ] 2with 1 -rot (each-integer) ; inline
index 959fd8bfd50cc1dfd160e71fd6acc283f0616e92..43c05ee207cf7566f006a2518677bd65d2e372aa 100644 (file)
@@ -16,7 +16,7 @@ IN: sorting.slots
             unclip-last-slice
             [ [ execute-accessor ] each ] dip
         ] when execute-comparator
-    ] with with map-find drop +eq+ or ;
+    ] 2with map-find drop +eq+ or ;
 
 : sort-by-with ( seq sort-specs quot: ( obj -- key ) -- seq' )
     swap '[ _ bi@ _ compare-slots ] sort ; inline
index 1a368c94468322e64864151f14dec3fd36dc9487..a492a9b567d05b57b6a9e16ec311efb4aaa820f5 100644 (file)
@@ -1,7 +1,7 @@
 ! (c)Joe Groff bsd license
 USING: accessors arrays classes classes.tuple combinators
-combinators.short-circuit definitions effects fry hints
-math kernel kernel.private namespaces parser quotations
+combinators.short-circuit definitions effects fry generalizations
+hints math kernel kernel.private namespaces parser quotations
 sequences slots words locals effects.parser
 locals.parser macros stack-checker.dependencies
 classes.maybe classes.algebra ;
@@ -52,7 +52,7 @@ PREDICATE: typed-word < word "typed-word" word-prop >boolean ;
     compose compose ;
 
 : make-unboxer ( error-quot word types -- quot )
-    dup [ unboxer ] with with with
+    dup [ unboxer ] 3 nwith
     [ swap \ dip [ ] 2sequence prepend ] map-reduce ;
 
 : (unboxed-types) ( type -- types )
@@ -128,7 +128,7 @@ M: typed-gensym where parent-word where ;
     [ 2nip ] 3tri define-declared ;
 
 MACRO: typed ( quot word effect -- quot' )
-    [ effect-in-types dup typed-stack-effect? [ typed-inputs ] [ 2drop ] if ] 
+    [ effect-in-types dup typed-stack-effect? [ typed-inputs ] [ 2drop ] if ]
     [
         nip effect-out-types dup typed-stack-effect?
         [ [ unboxed-types ] [ make-boxer ] bi '[ @ _ declare @ ] ] [ drop ] if
@@ -152,7 +152,7 @@ M: typed-word subwords
 PRIVATE>
 
 : define-typed ( word def effect -- )
-    [ [ 2drop ] [ typed-def ] [ 2nip ] 3tri define-inline ] 
+    [ [ 2drop ] [ typed-def ] [ 2nip ] 3tri define-inline ]
     [ drop "typed-def" set-word-prop ]
     [ 2drop "typed-word" word-prop set-last-word ] 3tri ;
 
index 70cc0bc971ff01d3ac4fd832da9ca1d10b6b5787..15569dbc1accdafd07cc78930bb29b3e8422f6ef 100644 (file)
@@ -57,7 +57,7 @@ M: ---- <menu-item>
     ] make-corners ;
 
 : <commands-menu> ( target hook commands -- menu )
-    [ <menu-item> ] with with map <menu> ;
+    [ <menu-item> ] 2with map <menu> ;
 
 : show-commands-menu ( target commands -- )
     [ dup [ ] ] dip <commands-menu> show-menu ;
index fdeb721e650e4110cddae96086bc72b26ace46f3..add0cbe677f745932152515fd0ec212932be703c 100644 (file)
@@ -13,7 +13,7 @@ IN: unicode.collation.tests
 \r
 : test-equality ( str1 str2 -- ? ? ? ? )\r
     { primary= secondary= tertiary= quaternary= }\r
-    [ execute( a b -- ? ) ] with with map\r
+    [ execute( a b -- ? ) ] 2with map\r
     first4 ;\r
 \r
 [ f f f f ] [ "hello" "hi" test-equality ] unit-test\r
index 38b5e9c9bfcba8f27ae0a916f45c6969e7a7859c..b907d33ebad8d60b30c4769c7568fb688a6e3135 100644 (file)
@@ -83,7 +83,7 @@ ducet get-global insert-helpers
 : add ( char -- )\r
     dup blocked? [ 1string , ] [\r
         dup possible-bases dup length iota\r
-        [ ?combine ] with with any?\r
+        [ ?combine ] 2with any?\r
         [ drop ] [ 1string , ] if\r
     ] if ;\r
 \r
index 1ff002d13a9cc508fb51b6e1d393885a503cfa71..7db83144a7bec2bec4be9de348401e5fea195834 100644 (file)
@@ -11,7 +11,7 @@ IN: vocabs.metadata.resources
     [ dup '[ _ directory-tree-files [ append-path ] with map ] [ prefix ] bi ]
     [ 1array ] if ;
 
-: filter-resources ( vocab-files resource-globs -- resource-files ) 
+: filter-resources ( vocab-files resource-globs -- resource-files )
     '[ _ [ matches? ] with any? ] filter ;
 
 : copy-vocab-resource ( to from file -- )
@@ -19,7 +19,7 @@ IN: vocabs.metadata.resources
     dup file-info directory?
     [ drop make-directories ]
     [ swap [ parent-directory make-directories ] [ copy-file ] bi ] if ;
-    
+
 PRIVATE>
 
 : vocab-dir-in-root ( vocab -- dir )
@@ -36,10 +36,9 @@ PRIVATE>
     [ drop f ] [ expand-vocab-resource-files ] if-empty ;
 
 : copy-vocab-resources ( dir vocab -- )
-    dup vocab-resource-files 
+    dup vocab-resource-files
     [ 2drop ] [
         [ [ vocab-dir append-path ] [ vocab-dir-in-root ] bi ] dip
         [ 2drop make-directories ]
-        [ [ copy-vocab-resource ] with with each ] 3bi
+        [ [ copy-vocab-resource ] 2with each ] 3bi
     ] if-empty ;
-
index 5c074cea219367624fd29ce51df2a1059dea0e11..96a3edf9c62c51dc34079cbfc3a5689a46ed0cdb 100644 (file)
@@ -118,7 +118,7 @@ M: math-combination perform-combination
     drop dup generic-word [
         dup [ over ] [
             dup math-class? [
-                [ dup ] [ math-method ] with with math-dispatch-step
+                [ dup ] [ math-method ] 2with math-dispatch-step
             ] [
                 drop object-method
             ] if
index 1ef45e2e7674b4f8c0560dc0752cad649027ce1b..207dd5807cdf63fed5f906c67d3439ff5656c973 100644 (file)
@@ -75,7 +75,7 @@ C: <predicate-engine> predicate-engine
 
 : flatten-method ( method class assoc -- )
     over flatten-class keys
-    [ swap push-method ] with with with each ;
+    [ swap push-method ] 2with with each ;
 
 : flatten-methods ( assoc -- assoc' )
     H{ } clone [ [ swapd flatten-method ] curry assoc-each ] keep ;
index 37b60d45b2e02e4cf884483f878981a5f72daa0d..e18d9f27cb5af2a37fb8e0275e2cc0b456387045 100644 (file)
@@ -777,9 +777,19 @@ HELP: with
 { $notes "This operation is efficient and does not copy the quotation." }
 { $examples
     { $example "USING: kernel math prettyprint sequences ;" "1 { 1 2 3 } [ / ] with map ." "{ 1 1/2 1/3 }" }
-    { $example "USING: kernel math prettyprint sequences ;" "1000 100 5 iota [ sq + + ] with with map ." "{ 1100 1101 1104 1109 1116 }" }
+    { $example "USING: kernel math prettyprint sequences ;" "1000 100 5 iota [ sq + + ] 2with map ." "{ 1100 1101 1104 1109 1116 }" }
 } ;
 
+HELP: 2with
+{ $values
+  { "param1" object }
+  { "param1" object }
+  { "obj" object }
+  { "quot" { $quotation ( param1 param2 elt -- ... ) } }
+  { "curry" curry }
+}
+{ $description "Partial application on the left of two parameters." } ;
+
 HELP: compose
 { $values { "quot1" callable } { "quot2" callable } { "compose" compose } }
 { $description "Quotation composition. Outputs a " { $link callable } " which calls " { $snippet "quot1" } " followed by " { $snippet "quot2" } "." }
@@ -951,4 +961,3 @@ ARTICLE: "assertions" "Assertions"
     assert
     assert=
 } ;
-
index c2fc444510bed2459d865602b316c77fa74352e2..03853429708eb649d827abaa3601cc1664813950 100644 (file)
@@ -8,6 +8,21 @@ IN: kernel.tests
 [ 0 ] [ f size ] unit-test
 [ t ] [ [ \ = \ = ] all-equal? ] unit-test
 
+[
+    {
+        { 1 2 0 }
+        { 1 2 1 }
+        { 1 2 2 }
+        { 1 2 3 }
+        { 1 2 4 }
+        { 1 2 5 }
+        { 1 2 6 }
+        { 1 2 7 }
+        { 1 2 8 }
+        { 1 2 9 }
+    }
+] [ 1 2 10 iota [ 3array ] 2with map ] unit-test
+
 ! Don't leak extra roots if error is thrown
 [ ] [ 1000 [ [ 3 throw ] ignore-errors ] times ] unit-test
 
index 72b1c59d1be120ac28775bb00a997c062c28ff85..a397331bcf6c1205f92f8f4a00a5b90e71b1f21b 100644 (file)
@@ -135,6 +135,9 @@ DEFER: if
 : with ( param obj quot -- obj curry )
     swapd [ swapd call ] 2curry ; inline
 
+: 2with ( param1 param2 obj quot -- obj curry )
+    with with ; inline
+
 : prepose ( quot1 quot2 -- compose )
     swap compose ; inline
 
index 866891dd31a7b9d31c63c4dc046bbd5a4dfe6b9a..13716b27c6fb0d4d4efa27394f8c8356be1dcc22 100644 (file)
@@ -1,7 +1,7 @@
 ! Factor port of the raytracer benchmark from
 ! http://www.ffconsultancy.com/languages/ray_tracer/index.html
 
-USING: arrays accessors io io.files io.files.temp
+USING: arrays accessors generalizations io io.files io.files.temp
 io.encodings.binary kernel math math.constants math.functions
 math.vectors math.vectors.simd math.vectors.simd.cords
 math.parser make sequences words combinators ;
@@ -129,7 +129,7 @@ CONSTANT: create-offsets
 : create-group ( level c r -- scene )
     2dup create-bound [
         2dup <sphere> ,
-        create-offsets [ create-step , ] with with with each
+        create-offsets [ create-step , ] 3 nwith each
     ] make-group ;
 
 : create ( level c r -- scene )
@@ -145,15 +145,15 @@ CONSTANT: create-offsets
             ss-point v+ normalize
             double-4{ 0.0 0.0 -4.0 0.0 } swap <ray>
             swap cast-ray +
-        ] with with with each
-    ] with with each ; inline no-compile
+        ] 3 nwith each
+    ] 2with each ; inline no-compile
 
 : ray-trace ( scene -- grid )
     size iota <reversed> [
         size iota [
             [ size 0.5 * - ] bi@ swap size
             0.0 double-4-boa ray-pixel
-        ] with with map
+        ] 2with map
     ] with map ;
 
 : pgm-header ( w h -- )
index e6dce0061a1ccc7f21df4bc8b20f5066d19aae4c..cf4719490a1e70cd893f2ca192375f7295aa9537 100644 (file)
@@ -78,12 +78,12 @@ STRUCT: yuv-buffer
 : yuv>rgb-row ( index rgb yuv y -- index )
     over stride
     pick y_width>> iota
-    [ yuv>rgb-pixel ] with with with with each ; inline
+    [ yuv>rgb-pixel ] 4 nwith each ; inline
 
 TYPED: yuv>rgb ( rgb: byte-array yuv: yuv-buffer -- )
     [ 0 ] 2dip
     dup y_height>> iota
-    [ yuv>rgb-row ] with with each
+    [ yuv>rgb-row ] 2with each
     drop ;
 
 : yuv-to-rgb-benchmark ( -- )
index 5119837be8e34e3797af2ffa1e5343196308c903..62fb1d8e98ed2da530435d1da233ba5937e0bd14 100644 (file)
@@ -20,7 +20,7 @@ TUPLE: boid
 C: <boid> boid
 
 : vsum ( vecs -- v )
-    { 0.0 0.0 } [ v+ ] reduce ; inline 
+    { 0.0 0.0 } [ v+ ] reduce ; inline
 
 : vavg ( vecs -- v )
     [ vsum ] [ length ] bi v/n ; inline
@@ -61,11 +61,11 @@ GENERIC: force ( neighbors boid behaviour -- force )
 : wrap-pos ( pos -- pos )
     width height [ 1 - ] bi@ 2array
     [ [ + ] keep mod ] 2map ;
-   
+
 :: simulate ( boids behaviours dt -- boids )
     boids [| boid |
         boid boids behaviours
-        [ [ (force) ] keep weight>> v*n ] with with map vsum :> a
+        [ [ (force) ] keep weight>> v*n ] 2with map vsum :> a
 
         boid vel>> a dt v*n v+ normalize :> vel
         boid pos>> vel dt v*n v+ wrap-pos :> pos
@@ -98,4 +98,3 @@ M:: separation force ( neighbors boid behaviour -- force )
     behaviour radius>> :> r
     boid pos>> neighbors
     [ pos>> v- [ normalize ] [ r v/n ] bi v- ] with map vsum ;
-
index c1ec085dc2e5ea447a1d96dad3bf84bd7de44a14..5aaf61d9dc8b7327369d8897c66ec3f5f37bcb8f 100644 (file)
@@ -30,7 +30,7 @@ IN: bunny.model
     vneg normalize ;
 
 : normal ( ns vs triple -- )
-    [ n ] keep [ rot [ v+ ] change-nth ] with with each ;
+    [ n ] keep [ rot [ v+ ] change-nth ] 2with each ;
 
 : normals ( vs is -- ns )
     [ [ length { 0.0 0.0 0.0 } <array> ] keep ] dip
@@ -55,7 +55,7 @@ CONSTANT: model-url "http://duriansoftware.com/joe/media/bun_zipper.ply"
     ] each ;
 
 : draw-triangles ( ns vs is -- )
-    GL_TRIANGLES [ [ (draw-triangle) ] with with each ] do-state ;
+    GL_TRIANGLES [ [ (draw-triangle) ] 2with each ] do-state ;
 
 TUPLE: bunny-dlist list ;
 TUPLE: bunny-buffers array element-array nv ni ;
index 2d3192279c490b77d31c8967c2a4dc7285dfaf8f..18773e79a46f35c64bb82d3f8e11fc81dc07f158 100644 (file)
@@ -47,7 +47,7 @@ M: x-up >y-up-axis!
         [ 0 swap nth ]
         [ 1 swap nth neg ]
         [ 2 swap nth ] tri
-        swap -rot 
+        swap -rot
     ] [
         [ 2 swap set-nth ]
         [ 1 swap set-nth ]
@@ -128,8 +128,8 @@ VERTEX-FORMAT: collada-vertex-format
         [
             [
                 [ data>> ] [ offset>> ] bi
-                rot = [ nth ] [ 2drop f ] if 
-            ] with with map sift flatten ,
+                rot = [ nth ] [ 2drop f ] if
+            ] 2with map sift flatten ,
         ] curry each-index
     ] V{ } make flatten ;
 
@@ -146,14 +146,14 @@ VERTEX-FORMAT: collada-vertex-format
         group-indices
     ]
     [
-        soa>aos 
+        soa>aos
         [ flatten c:float >c-array ]
         [ flatten c:uint >c-array ]
         bi* collada-vertex-format f model boa
     ] bi ;
-    
+
 : mesh>triangles ( sources vertices mesh-tag -- models )
-    "triangles" tags-named [ triangles>model ] with with map ;
+    "triangles" tags-named [ triangles>model ] 2with map ;
 
 : mesh>models ( mesh-tag -- models )
     [
index a39b8ac9b81c17ff89c254e98237b1c9d18bb5b6..ce1bd4b971d2e1b4d5ff10f24dc916adc49328af 100644 (file)
@@ -110,7 +110,7 @@ M: sequence selected-vectors [ selected-vectors ] map concat ;
     selected selected-vertices :> ( sel-vertices sel-count )\r
     face-vertices face-count edge-vertices edge-count sel-vertices sel-count\r
     <b-rep-vertices> :> vertices\r
-    \r
+\r
     vertices array>>\r
 \r
     face-indices\r
@@ -163,11 +163,11 @@ TYPED: refresh-b-rep-view ( world: gml-viewer-world -- )
 M: gml-viewer-world model-changed\r
     nip\r
     [ model>> value>> ]\r
-    [ b-rep<< ] \r
+    [ b-rep<< ]\r
     [ dup viewable? [ refresh-b-rep-view ] [ drop ] if ] tri ;\r
 \r
 : init-viewer-model ( gml-viewer-world -- )\r
-    [ dup model>> add-connection ] \r
+    [ dup model>> add-connection ]\r
     [ dup selected>> add-connection ] bi ;\r
 \r
 : reset-view ( gml-viewer-world -- )\r
@@ -192,7 +192,7 @@ M: gml-viewer-world draw-world*
         { default-attachment { 0.0 0.0 0.0 1.0 } }\r
         { depth-attachment 1.0 }\r
     } clear-framebuffer\r
-    \r
+\r
     [\r
         dup view-faces?>> [\r
             T{ depth-state { comparison cmp-less } } set-gpu-state\r
@@ -213,7 +213,7 @@ M: gml-viewer-world draw-world*
                 { "vertex-array"   [ vertex-array>> ] }\r
             } <render-set> render\r
         ] [ drop ] if\r
-    ] [ \r
+    ] [\r
         {\r
             { "primitive-mode" [ drop points-mode ] }\r
             { "indexes"        [ point-indices>> ] }\r
@@ -258,7 +258,7 @@ CONSTANT: edge-hitbox-radius 0.05
     ] [ f ] if ;\r
 \r
 : intersecting-edge-node ( source direction b-rep -- edge/f )\r
-    edges>> [ intersects-edge-node? ] with with find nip ;\r
+    edges>> [ intersects-edge-node? ] 2with find nip ;\r
 \r
 : select-edge ( world -- )\r
     [ [ location>> ] [ hand-loc get wasd-pixel-ray ] bi ]\r
@@ -311,4 +311,3 @@ M: gml-viewer-world wasd-mouse-scale drag?>> -1/600. 0.0 ? ;
         _ >>selected\r
         drop\r
     ] with-ui ;\r
-\r
index 3066f7b7216d673b79333a7c407ac4ac5b5ef562..0168289455ad7bdf15f0da2bc06c7e60fc7a679e 100644 (file)
@@ -59,7 +59,7 @@ IN: graphviz.notation
         name>>
         [ attrs-obj-=attr ] keep
         graph-obj-=attr
-    ] with with each ;
+    ] 2with each ;
 
 PRIVATE>
 
index d2b2e1599968e36bd0a539a87dac973c13879962..f3440725bf15558b654e8fac7fadb0c3bf3e8d02 100644 (file)
@@ -28,7 +28,7 @@ M: irc-channel-chat has-participant? participants>> key? ;
     dup participant-chats [ part-participant ] with each ;
 
 : rename-participant* ( new old -- )
-    [ dup participant-chats [ rename-participant ] with with each ]
+    [ dup participant-chats [ rename-participant ] 2with each ]
     [ dup chat> [ rename-nick-chat ] [ 2drop ] if ]
     2bi ;
 
index ead78200fd5ed2f442ffedf0b192bcb56be9c5df..662162f5327e1a6f7be106cbfb129c8b270233d5 100644 (file)
@@ -163,7 +163,7 @@ DEFER: (d)
     swap call [ at 0 or ] curry map ; inline
 
 : op-matrix ( domain range quot -- matrix )
-    rot [ (op-matrix) ] with with map ; inline
+    rot [ (op-matrix) ] 2with map ; inline
 
 : d-matrix ( domain range -- matrix )
     [ (d) ] op-matrix ;
@@ -260,8 +260,8 @@ DEFER: (d)
 
 : bigraded-triple ( u-deg z-deg bigraded-basis -- triple )
     #! d: C(u,z) ---> C(u+2,z-1)
-    [ [ 2 - ] [ 1 + ] [ ] tri* ?nth ?nth ] 
-    [ ?nth ?nth ] 
+    [ [ 2 - ] [ 1 + ] [ ] tri* ?nth ?nth ]
+    [ ?nth ?nth ]
     [ [ 2 + ] [ 1 - ] [ ] tri* ?nth ?nth ]
     3tri
     3array ;
index 38ab0c31da2e16f4efc46eadf084ada94a624a4d..858e1f7401c1e8ab38bf7cb625e265aa2a7f6ca8 100644 (file)
@@ -8,7 +8,7 @@ IN: nurbs
 
 TUPLE: nurbs-curve
     { order integer }
-    control-points 
+    control-points
     knots
     (knot-constants) ;
 
@@ -32,7 +32,7 @@ TUPLE: nurbs-curve
 
 : order-knot-constants ( curve order -- knot-constants )
     2dup [ knots>> length ] dip - iota
-    [ order-index-knot-constants ] with with map ;
+    [ order-index-knot-constants ] 2with map ;
 
 : knot-constants ( curve -- knot-constants )
     2 over order>> [a,b]
@@ -71,5 +71,3 @@ TUPLE: nurbs-curve
 
 : eval-nurbs ( nurbs-curve t -- value )
     2dup knot-interval 1 - { 1.0 } 2 (eval-bases) ;
-
-
index 4f388e0e18294c674ecb1ad9b02d4434f3476249..e17eeaa71e611b1a2ccf0aacb1c2c53f0497a78c 100644 (file)
@@ -22,9 +22,6 @@ ERROR: pcre-error value ;
 : split-subseqs ( seq subseqs -- seqs )
     dup first [ replace-all ] keep split-subseq [ >string ] map harvest ;
 
-: 2with ( param1 param2 obj quot -- obj curry )
-    [ -rot ] dip [ [ rot ] dip call ] 3curry ; inline
-
 : utf8-start-byte? ( byte -- ? )
     0xc0 bitand 0x80 = not ;
 
index f9ae9393fcfb80dc54ec3b6bed25fd354a439610..261a9e8ff20b5167c33039d9990da895a8c706a9 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (c) 2010 Samuel Tardieu.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.functions project-euler.common sequences sets ;
+USING: generalizations kernel math math.functions project-euler.common
+sequences sets ;
 IN: project-euler.265
 
 ! http://projecteuler.net/index.php?section=problems&id=265
@@ -51,7 +52,7 @@ CONSTANT: N 5
         nip ?register
     ] [
         [ 1 - ] dip
-        { 0 1 } [ add-bit [ iterate ] [ 3drop ] if ] with with with each
+        { 0 1 } [ add-bit [ iterate ] [ 3drop ] if ] 3 nwith each
     ] if ;
 
 : euler265 ( -- answer )
index 7c4b588ea267a8c803911b29e910926319f6813c..47ab274cd1ae2458aee760ff1237818280882f8a 100644 (file)
@@ -1,5 +1,5 @@
 ! Based on http://www.ffconsultancy.com/ocaml/sudoku/index.html
-USING: columns combinators combinators.short-circuit io
+USING: columns combinators combinators.short-circuit generalizations io
 io.styles kernel math math.parser namespaces sequences ;
 IN: sudoku
 
@@ -17,7 +17,7 @@ SYMBOL: board
 : cell-any? ( n x y i -- ? ) 3 /mod pair+ board> = ;
 
 : box-any? ( n x y -- ? )
-    [ 3 /i 3 * ] bi@ 9 iota [ cell-any? ] with with with any? ;
+    [ 3 /i 3 * ] bi@ 9 iota [ cell-any? ] 3 nwith any? ;
 
 : board-any? ( n x y -- ? )
     { [ nip row-any? ] [ drop col-any? ] [ box-any? ] } 3|| ;
index 29f710061c4b02ecfad9120d63f4a0fa83aa7baa..111ea991592d9b2a16fca566b27ac8dbe2dab5b9 100644 (file)
@@ -49,7 +49,7 @@ MEMO: cities-named ( name -- cities )
 MEMO: cities-named-in ( name state -- cities )
     cities [
         [ name>> = ] [ state>> = ] bi-curry bi* and
-    ] with with filter ;
+    ] 2with filter ;
 
 : find-zip-code ( code -- city )
     cities [ first-zip>> <=> ] with search nip ;
index 72811a2c7b18e275702ee1276b47ebb2358f84f2..0db5ba62df7165f9baa6e07be7f4516e53aa040c 100644 (file)
@@ -39,6 +39,6 @@ M: window-controls-demo-world pref-dim*
         open-window*
             windows >>windows
             windows push
-    ] with with assoc-each ;
+    ] 2with assoc-each ;
 
 MAIN: window-controls-demo
index 15491667b8a535fdeda38922dda31546da118583..2a850eec96c1a51a37b09dad06be9bf86ed7c521 100644 (file)
@@ -426,7 +426,7 @@ M:: yaml-alias emit-value ( emitter event unused obj -- )
     yaml_emitter_emit_asserted ;
 
 : emit-sequence-body ( emitter event seq -- )
-    [ emit-object ] with with each ;
+    [ emit-object ] 2with each ;
 
 : emit-assoc-body ( emitter event assoc -- )
     [
@@ -534,5 +534,5 @@ PRIVATE>
 : >yaml-docs ( seq -- str )
     [
         [ init-emitter ] dip
-        [ [ replace-identities emit-doc ] with with each ] [ drop flush-emitter ] 3bi
+        [ [ replace-identities emit-doc ] 2with each ] [ drop flush-emitter ] 3bi
     ] with-destructors ;