]> gitweb.factorcode.org Git - factor.git/commitdiff
Removing integers-as-sequences
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 14 Jan 2010 15:10:13 +0000 (04:10 +1300)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 14 Jan 2010 18:15:33 +0000 (07:15 +1300)
155 files changed:
basis/base64/base64.factor
basis/binary-search/binary-search-tests.factor
basis/bit-arrays/bit-arrays-tests.factor
basis/bit-arrays/bit-arrays.factor
basis/bit-vectors/bit-vectors-tests.factor
basis/calendar/calendar-tests.factor
basis/calendar/format/format.factor
basis/checksums/sha/sha.factor
basis/classes/struct/bit-accessors/bit-accessors-tests.factor
basis/cocoa/messages/messages.factor
basis/columns/columns-tests.factor
basis/columns/columns.factor
basis/combinators/smart/smart.factor
basis/compiler/cfg/instructions/syntax/syntax.factor
basis/compiler/cfg/intrinsics/allot/allot.factor
basis/compiler/cfg/stacks/stacks.factor
basis/compiler/cfg/stacks/uninitialized/uninitialized.factor
basis/compiler/codegen/codegen.factor
basis/compiler/tests/alien.factor
basis/compiler/tests/codegen.factor
basis/compiler/tests/intrinsics.factor
basis/compiler/tests/optimizer.factor
basis/compiler/tree/cleanup/cleanup-tests.factor
basis/compiler/tree/dead-code/branches/branches.factor
basis/compiler/tree/dead-code/recursive/recursive.factor
basis/compiler/tree/dead-code/simple/simple.factor
basis/compiler/tree/debugger/debugger.factor
basis/compiler/tree/escape-analysis/recursive/recursive-tests.factor
basis/compiler/tree/modular-arithmetic/modular-arithmetic-tests.factor
basis/compiler/tree/normalization/normalization.factor
basis/compiler/tree/propagation/call-effect/call-effect.factor
basis/compiler/tree/propagation/info/info-tests.factor
basis/compiler/tree/propagation/propagation-tests.factor
basis/compiler/tree/propagation/simple/simple.factor
basis/compiler/tree/propagation/transforms/transforms.factor
basis/compression/inflate/inflate.factor
basis/concurrency/combinators/combinators-tests.factor
basis/db/db.factor
basis/db/queries/queries.factor
basis/db/tester/tester.factor
basis/farkup/farkup-tests.factor
basis/fry/fry-tests.factor
basis/generalizations/generalizations-tests.factor
basis/heaps/heaps-tests.factor
basis/hints/hints.factor
basis/inspector/inspector.factor
basis/inverse/inverse.factor
basis/io/encodings/iso2022/iso2022.factor
basis/io/files/links/unix/unix-tests.factor
basis/io/files/unique/unique.factor
basis/lcs/diff2html/diff2html-tests.factor
basis/lcs/diff2html/diff2html.factor
basis/lcs/lcs.factor
basis/macros/expander/expander.factor
basis/math/combinatorics/combinatorics-tests.factor
basis/math/combinatorics/combinatorics.factor
basis/math/intervals/intervals-tests.factor
basis/math/matrices/elimination/elimination.factor
basis/math/matrices/matrices.factor
basis/math/polynomials/polynomials.factor
basis/math/primes/miller-rabin/miller-rabin-tests.factor
basis/math/primes/miller-rabin/miller-rabin.factor
basis/math/primes/primes.factor
basis/math/vectors/simd/cords/cords.factor
basis/math/vectors/simd/intrinsics/intrinsics.factor
basis/math/vectors/simd/simd-tests.factor
basis/math/vectors/simd/simd.factor
basis/models/arrow/smart/smart.factor
basis/nibble-arrays/nibble-arrays-tests.factor
basis/peg/ebnf/ebnf.factor
basis/persistent/hashtables/hashtables-tests.factor
basis/persistent/vectors/vectors-tests.factor
basis/porter-stemmer/porter-stemmer.factor
basis/prettyprint/sections/sections.factor
basis/random/mersenne-twister/mersenne-twister-tests.factor
basis/random/mersenne-twister/mersenne-twister.factor
basis/random/random-tests.factor
basis/regexp/disambiguate/disambiguate.factor
basis/roman/roman.factor
basis/serialize/serialize-tests.factor
basis/serialize/serialize.factor
basis/shuffle/shuffle.factor
basis/sorting/insertion/insertion.factor
basis/splitting/monotonic/monotonic.factor
basis/stack-checker/errors/prettyprint/prettyprint.factor
basis/stack-checker/inlining/inlining.factor
basis/stack-checker/known-words/known-words.factor
basis/stack-checker/stack-checker-tests.factor
basis/stack-checker/state/state.factor
basis/strings/tables/tables.factor
basis/suffix-arrays/suffix-arrays.factor
basis/threads/threads-tests.factor
basis/tr/tr.factor
basis/tuple-arrays/tuple-arrays.factor
basis/ui/gadgets/gadgets-tests.factor
basis/ui/gadgets/packs/packs-tests.factor
basis/ui/gadgets/panes/panes-tests.factor
basis/ui/gadgets/scrollers/scrollers-tests.factor
basis/ui/gadgets/slots/slots-tests.factor
basis/unicode/breaks/breaks-tests.factor
basis/unicode/breaks/breaks.factor
basis/unicode/collation/collation.factor
basis/unicode/data/data.factor
basis/unix/unix.factor
basis/unrolled-lists/unrolled-lists-tests.factor
basis/xml/tests/xmltest.factor
basis/xml/tokenize/tokenize.factor
core/assocs/assocs.factor
core/byte-vectors/byte-vectors-tests.factor
core/classes/algebra/algebra-tests.factor
core/continuations/continuations-tests.factor
core/effects/effects-docs.factor
core/effects/effects-tests.factor
core/effects/effects.factor
core/hashtables/hashtables-tests.factor
core/io/encodings/utf8/utf8-tests.factor
core/math/floats/floats-tests.factor
core/math/integers/integers-tests.factor
core/sbufs/sbufs-tests.factor
core/sequences/sequences-docs.factor
core/sequences/sequences-tests.factor
core/sequences/sequences.factor
core/sorting/sorting-tests.factor
core/source-files/errors/errors.factor
core/strings/strings-tests.factor
core/vectors/vectors-tests.factor
extra/benchmark/iteration/iteration.factor
extra/bloom-filters/bloom-filters-tests.factor
extra/crypto/aes/aes.factor
extra/decimals/decimals-tests.factor
extra/html/parser/analyzer/analyzer.factor
extra/id3/id3-tests.factor
extra/jamshred/tunnel/tunnel.factor
extra/koszul/koszul.factor
extra/math/analysis/analysis.factor
extra/math/text/english/english.factor
extra/memory/pools/pools.factor
extra/multi-methods/multi-methods.factor
extra/partial-continuations/partial-continuations-tests.factor
extra/project-euler/011/011.factor
extra/project-euler/014/014.factor
extra/project-euler/024/024.factor
extra/project-euler/032/032.factor
extra/project-euler/043/043.factor
extra/project-euler/052/052.factor
extra/project-euler/053/053.factor
extra/project-euler/150/150.factor
extra/project-euler/151/151.factor
extra/project-euler/164/164.factor
extra/project-euler/common/common.factor
extra/slides/slides.factor
extra/smalltalk/compiler/compiler-tests.factor
extra/smalltalk/selectors/selectors.factor
extra/tetris/board/board.factor
extra/trees/splay/splay-tests.factor

index eb2c9193a374b35e61a33a2f510f4c2582eaf04e..1a0648cef8b92f2037438ddc2686e24617e3ade3 100644 (file)
@@ -13,7 +13,8 @@ ERROR: malformed-base64 ;
     read1 2dup swap member? [ drop read1-ignoring ] [ nip ] if ;
 
 : read-ignoring ( ignoring n -- str )
-    [ drop read1-ignoring ] with map harvest
+    [ drop read1-ignoring ] with { } map-integers
+    [ { f 0 } member? not ] filter
     [ f ] [ >string ] if-empty ;
 
 : ch>base64 ( ch -- ch )
@@ -42,7 +43,7 @@ SYMBOL: column
     [ write1-lines ] each ;
 
 : encode3 ( seq -- )
-    be> 4 <reversed> [
+    be> 4 iota <reversed> [
         -6 * shift HEX: 3f bitand ch>base64 write1-lines
     ] with each ; inline
 
index f2ea7503f4851f8a8ac6bdb371a21237053d03ce..a797219a01466894624323ce5832c0965f4cec64 100644 (file)
@@ -1,4 +1,4 @@
-USING: binary-search math.order vectors kernel tools.test ;
+USING: binary-search math.order sequences kernel tools.test ;
 IN: binary-search.tests
 
 [ f ] [ 3 { } [ <=> ] with search drop ] unit-test
@@ -7,7 +7,7 @@ IN: binary-search.tests
 [ 3 ] [ 4 { 1 2 3 4 5 6 } [ <=> ] with search drop ] unit-test
 [ 2 ] [ 3.5 { 1 2 3 4 5 6 7 8 } [ <=> ] with search drop ] unit-test
 [ 4 ] [ 5.5 { 1 2 3 4 5 6 7 8 } [ <=> ] with search drop ] unit-test
-[ 10 ] [ 10 20 >vector [ <=> ] with search drop ] unit-test
+[ 10 ] [ 10 20 iota [ <=> ] with search drop ] unit-test
 
 [ t ] [ "hello" { "alligator" "cat" "fish" "hello" "ikarus" "java" } sorted-member? ] unit-test
 [ 3 ] [ "hey" { "alligator" "cat" "fish" "hello" "ikarus" "java" } sorted-index ] unit-test
index 7397791ab5b1b05058058d87fade66942c1ccb6d..fbf0d4b639940e0c193681368cf1b99f31a71239 100644 (file)
@@ -38,9 +38,9 @@ IN: bit-arrays.tests
 
 [ t ] [
     100 [
-        drop 100 [ 2 random zero? ] replicate
+        drop 100 [ 2 iota random zero? ] replicate
         dup >bit-array >array =
-    ] all?
+    ] all-integers?
 ] unit-test
 
 [ ?{ f } ] [
index f5613da6b552126b3edf31b7e494179c0246a9c0..4fafc528fdcb7728633915184f4ec5e97f23cdb8 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2007, 2008 Slava Pestov.
+! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types alien.data accessors math alien.accessors kernel
 kernel.private sequences sequences.private byte-arrays
@@ -25,7 +25,7 @@ TUPLE: bit-array
 
 : (set-bits) ( bit-array n -- )
     [ [ length bits>cells ] keep ] dip swap underlying>>
-    '[ 2 shift [ _ _ ] dip set-alien-unsigned-4 ] each ; inline
+    '[ 2 shift [ _ _ ] dip set-alien-unsigned-4 ] each-integer ; inline
 
 : clean-up ( bit-array -- )
     ! Zero bits after the end.
@@ -99,7 +99,7 @@ SYNTAX: ?{ \ } [ >bit-array ] parse-literal ;
     ] if ;
 
 : bit-array>integer ( bit-array -- n )
-    0 swap underlying>> dup length <reversed> [
+    0 swap underlying>> dup length iota <reversed> [
         alien-unsigned-1 swap 8 shift bitor
     ] with each ;
 
index 5af44b59f7f30577e24a753a74c4565fe1f03689..a8a856ffd00476e73a9bef035886d965cfa0fd92 100644 (file)
@@ -4,7 +4,7 @@ IN: bit-vectors.tests
 [ 0 ] [ 123 <bit-vector> length ] unit-test\r
 \r
 : do-it ( seq -- )\r
-    1234 swap [ [ even? ] dip push ] curry each ;\r
+    1234 swap [ [ even? ] dip push ] curry each-integer ;\r
 \r
 [ t ] [\r
     3 <bit-vector> dup do-it\r
index 2490b87c374b0876dc6bf991d2b7ec232f305a31..eb565a18d443ac781ec1643fafd91e2e0e71908d 100644 (file)
@@ -175,4 +175,4 @@ IN: calendar.tests
 [ t ] [ 1325376000 unix-time>timestamp 2012 <year-gmt> = ] unit-test
 [ t ] [ 1356998399 unix-time>timestamp 2013 <year-gmt> 1 seconds time- = ] unit-test
 
-[ t ] [ 1500000000 random [ unix-time>timestamp timestamp>unix-time ] keep = ] unit-test
+[ t ] [ 1500000000 iota random [ unix-time>timestamp timestamp>unix-time ] keep = ] unit-test
index d07d74722a71de9c45ad58b231d55b71acd54a3b..96d76d0ce86430c5e7b9badbd0502b7393f8aba8 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.\r
+! Copyright (C) 2008, 2010 Slava Pestov, Doug Coleman.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: math math.order math.parser math.functions kernel\r
 sequences io accessors arrays io.streams.string splitting\r
@@ -70,7 +70,7 @@ M: array month. ( pair -- )
     [\r
         [ 1 + day. ] keep\r
         1 + + 7 mod zero? [ nl ] [ bl ] if\r
-    ] with each nl ;\r
+    ] with each-integer nl ;\r
 \r
 M: timestamp month. ( timestamp -- )\r
     [ year>> ] [ month>> ] bi 2array month. ;\r
@@ -78,7 +78,7 @@ M: timestamp month. ( timestamp -- )
 GENERIC: year. ( obj -- )\r
 \r
 M: integer year. ( n -- )\r
-    12 [ 1 + 2array month. nl ] with each ;\r
+    12 [ 1 + 2array month. nl ] with each-integer ;\r
 \r
 M: timestamp year. ( timestamp -- )\r
     year>> year. ;\r
index 35262bb0b0fb718103d9b3ef39138a598f86effd..ba85add03c63727406fb6d650b5f745b2b911e68 100644 (file)
@@ -301,7 +301,7 @@ GENERIC: pad-initial-bytes ( string sha2 -- padded-string )
         M cloned-H sha2 T1-256
         cloned-H T2-256
         cloned-H update-H
-    ] each
+    ] each-integer
     sha2 [ cloned-H [ w+ ] 2map ] change-H drop ; inline
 
 M: sha2-short checksum-block
@@ -391,7 +391,7 @@ M: sha-256 checksum-stream ( stream checksum -- byte-array )
         b H nth-unsafe 30 bitroll-32 c H set-nth-unsafe
         a H nth-unsafe b H set-nth-unsafe
         a H set-nth-unsafe
-    ] each
+    ] each-integer
     state [ H [ w+ ] 2map ] change-H drop ; inline
 
 M:: sha1-state checksum-block ( bytes state -- )
index e2ff6dbd9c5c15e834f0bcb05f28f2c43fa22e01..037b316363b732428306795ca026b248bf92ef78 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2009 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: classes.struct.bit-accessors tools.test effects kernel random stack-checker ;
+USING: classes.struct.bit-accessors tools.test effects kernel
+sequences random stack-checker ;
 IN: classes.struct.bit-accessors.test
 
-[ t ] [ 20 random 20 random bit-reader infer (( alien -- n )) effect= ] unit-test
-[ t ] [ 20 random 20 random bit-writer infer (( n alien -- )) effect= ] unit-test
+[ t ] [ 20 iota random 20 iota random bit-reader infer (( alien -- n )) effect= ] unit-test
+[ t ] [ 20 iota random 20 iota random bit-writer infer (( n alien -- )) effect= ] unit-test
index 4cc9554d3c4be5b84d1be3a1f09b7ceabd02fded..02e6335c54b5f4f2a7a628721d7647df412025a2 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2006, 2009 Slava Pestov.
+! Copyright (C) 2006, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.strings arrays assocs
 classes.struct continuations combinators compiler compiler.alien
@@ -202,7 +202,7 @@ ERROR: no-objc-type name ;
     (free) ;
 
 : method-arg-types ( method -- args )
-    dup method_getNumberOfArguments
+    dup method_getNumberOfArguments iota
     [ method-arg-type ] with map ;
 
 : method-return-type ( method -- ctype )
index 434c2339368a24b1970dcd1a20e938f5df79e010..c0e0956709582c1421577dc4accf9af2488b62c5 100644 (file)
@@ -7,3 +7,5 @@ IN: columns.tests
 [ { 1 4 7 } ] [ "seq" get 0 <column> >array ] unit-test
 [ ] [ "seq" get 1 <column> [ sq ] map! drop ] unit-test
 [ { 4 25 64 } ] [ "seq" get 1 <column> >array ] unit-test
+
+[ { { 1 3 } { 2 4 } } ] [ { { 1 2 } { 3 4 } } <flipped> [ >array ] map ] unit-test
index 8674217655c572e0bf977279d2fd3c9dc251882d..c36505ab6d1d727f091ff83be941935005fd1c10 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2008 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2005, 2010 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: sequences kernel accessors ;
 IN: columns
@@ -15,4 +15,4 @@ M: column length seq>> length ;
 INSTANCE: column virtual-sequence
 
 : <flipped> ( seq -- seq' )
-    dup empty? [ dup first length [ <column> ] with map ] unless ;
+    dup empty? [ dup first length [ <column> ] with { } map-integers ] unless ;
index 91987e0dfa6577f05a1d3b492ab56a6279ce33dd..e423bf84f8682291f3ae2fc883333fdfdfbb81e7 100644 (file)
@@ -4,50 +4,58 @@ USING: accessors fry generalizations kernel macros math.order
 stack-checker math sequences ;
 IN: combinators.smart
 
+<PRIVATE
+
+: inputs ( quot -- n ) infer in>> length ;
+
+: outputs ( quot -- n ) infer out>> length ;
+
+PRIVATE>
+
 MACRO: drop-outputs ( quot -- quot' )
-    dup infer out>> '[ @ _ ndrop ] ;
+    dup outputs '[ @ _ ndrop ] ;
 
 MACRO: keep-inputs ( quot -- quot' )
-    dup infer in>> '[ _ _ nkeep ] ;
+    dup inputs '[ _ _ nkeep ] ;
 
 MACRO: output>sequence ( quot exemplar -- newquot )
-    [ dup infer out>> ] dip
+    [ dup outputs ] dip
     '[ @ _ _ nsequence ] ;
 
 MACRO: output>array ( quot -- newquot )
     '[ _ { } output>sequence ] ;
 
 MACRO: input<sequence ( quot -- newquot )
-    [ infer in>> ] keep
+    [ inputs ] keep
     '[ _ firstn @ ] ;
 
 MACRO: input<sequence-unsafe ( quot -- newquot )
-    [ infer in>> ] keep
+    [ inputs ] keep
     '[ _ firstn-unsafe @ ] ;
 
 MACRO: reduce-outputs ( quot operation -- newquot )
-    [ dup infer out>> 1 [-] ] dip n*quot compose ;
+    [ dup outputs 1 [-] ] dip n*quot compose ;
 
 MACRO: sum-outputs ( quot -- n )
     '[ _ [ + ] reduce-outputs ] ;
 
 MACRO: map-reduce-outputs ( quot mapper reducer -- newquot )
-    [ dup infer out>> ] 2dip
+    [ dup outputs ] 2dip
     [ swap '[ _ _ napply ] ]
     [ [ 1 [-] ] dip n*quot ] bi-curry* bi
     '[ @ @ @ ] ;
 
 MACRO: append-outputs-as ( quot exemplar -- newquot )
-    [ dup infer out>> ] dip '[ @ _ _ nappend-as ] ;
+    [ dup outputs ] dip '[ @ _ _ nappend-as ] ;
 
 MACRO: append-outputs ( quot -- seq )
     '[ _ { } append-outputs-as ] ;
 
 MACRO: preserving ( quot -- )
-    [ infer in>> length ] keep '[ _ ndup @ ] ;
+    [ inputs ] keep '[ _ ndup @ ] ;
 
 MACRO: nullary ( quot -- quot' )
-    dup infer out>> length '[ @ _ ndrop ] ;
+    dup outputs '[ @ _ ndrop ] ;
 
 MACRO: smart-if ( pred true false -- )
     '[ _ preserving _ _ if ] ; inline
index bca5e1ee64491c2c8956fd7c74e5f40bc8ca725b..cd76652d06076508be8cfaa3308093cc26c23ef8 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: classes.tuple classes.tuple.parser kernel words
 make fry sequences parser accessors effects namespaces
@@ -61,14 +61,14 @@ TUPLE: insn-slot-spec type name rep ;
     "pure-insn" "compiler.cfg.instructions" lookup ;
 
 : insn-effect ( word -- effect )
-    boa-effect in>> but-last f <effect> ;
+    boa-effect in>> but-last { } <effect> ;
 
 : define-insn-tuple ( class superclass specs -- )
     [ name>> ] map "insn#" suffix define-tuple-class ;
 
 : define-insn-ctor ( class specs -- )
     [ dup '[ _ ] [ f ] [ boa , ] surround ] dip
-    [ name>> ] map f <effect> define-declared ;
+    [ name>> ] map { } <effect> define-declared ;
 
 : define-insn ( class superclass specs -- )
     parse-insn-slot-specs {
index 9804244ecb939da2a2d7d5996b808f9b4b61019c..31a8a898bc1fb07837e1a88425dda876e0f27210 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math math.order sequences accessors arrays
 byte-arrays layouts classes.tuple.private fry locals
@@ -34,7 +34,7 @@ IN: compiler.cfg.intrinsics.allot
     [ [ ^^load-literal ] dip 1 ] dip type-number ##set-slot-imm ;
 
 :: store-initial-element ( len reg elt class -- )
-    len [ [ elt reg ] dip 2 + class type-number ##set-slot-imm ] each ;
+    len [ [ elt reg ] dip 2 + class type-number ##set-slot-imm ] each-integer ;
 
 : expand-<array>? ( obj -- ? )
     dup integer? [ 0 8 between? ] [ drop f ] if ;
index ce673ba5bb4da2a317347c3763ffb9bb29ec18dc..6cf362c2308a4f278c09e04db1dc48cbf63c7691 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math sequences kernel namespaces accessors biassocs compiler.cfg
 compiler.cfg.instructions compiler.cfg.registers compiler.cfg.hats
@@ -33,7 +33,7 @@ IN: compiler.cfg.stacks
 : ds-load ( n -- vregs )
     dup 0 =
     [ drop f ]
-    [ [ <reversed> [ <ds-loc> peek-loc ] map ] [ neg inc-d ] bi ] if ;
+    [ [ iota <reversed> [ <ds-loc> peek-loc ] map ] [ neg inc-d ] bi ] if ;
 
 : ds-store ( vregs -- )
     [
index 0bed759e5286d615932726245ce860e5f772f123..e5fbfa6c40bcbafa674be12d46eb07044682a640 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences byte-arrays namespaces accessors classes math
 math.order fry arrays combinators compiler.cfg.registers
@@ -55,7 +55,7 @@ M: insn visit-insn drop ;
     2dup [ length ] bi@ max '[ _ 1 pad-tail ] bi@ [ bitand ] 2map ;
 
 : (uninitialized-locs) ( seq quot -- seq' )
-    [ dup length [ drop 0 = ] pusher [ 2each ] dip ] dip map ; inline
+    [ [ drop 0 = ] pusher [ each-index ] dip ] dip map ; inline
 
 PRIVATE>
 
index d408c722ff3bc56133faf952b57345f4e6d0583e..ef6794e9fab212dd8c656d3875311df96b73b088 100644 (file)
@@ -380,7 +380,7 @@ M: c-type-name flatten-value-type c-type flatten-value-type ;
     [ [ parameter-offsets nip ] keep ] dip 2reverse-each ; inline
 
 : prepare-unbox-parameters ( parameters -- offsets types indices )
-    [ parameter-offsets nip ] [ ] [ length iota reverse ] tri ;
+    [ parameter-offsets nip ] [ ] [ length iota <reversed> ] tri ;
 
 : unbox-parameters ( offset node -- )
     parameters>> swap
index 5e49e2d28d016f5fc5415f42017991af4da9cbc5..4cfbe8f6fa03bc7de20c0818cb42ad08014d10fe 100644 (file)
@@ -164,7 +164,7 @@ FUNCTION: void ffi_test_20 double x1, double x2, double x3,
     { int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int }
     alien-invoke gc 3 ;
 
-[ 861 3 ] [ 42 [ ] each ffi_test_31 ] unit-test
+[ 861 3 ] [ 42 [ ] each-integer ffi_test_31 ] unit-test
 
 : ffi_test_31_point_5 ( a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a -- result )
     float
@@ -172,7 +172,7 @@ FUNCTION: void ffi_test_20 double x1, double x2, double x3,
     { float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float }
     alien-invoke ;
 
-[ 861.0 ] [ 42 [ >float ] each ffi_test_31_point_5 ] unit-test
+[ 861.0 ] [ 42 [ >float ] each-integer ffi_test_31_point_5 ] unit-test
 
 FUNCTION: longlong ffi_test_21 long x long y ;
 
@@ -316,7 +316,7 @@ FUNCTION: ulonglong ffi_test_38 ( ulonglong x, ulonglong y ) ;
 
 : callback-1 ( -- callback ) void { } "cdecl" [ ] alien-callback ;
 
-[ 0 1 ] [ [ callback-1 ] infer [ in>> ] [ out>> ] bi ] unit-test
+[ 0 1 ] [ [ callback-1 ] infer [ in>> length ] [ out>> length ] bi ] unit-test
 
 [ t ] [ callback-1 alien? ] unit-test
 
index eba65805746b39c2b1466639b1935ff4013f8c4a..cff685eaf6e7066d059a0704561a15c1c1ed7c93 100644 (file)
@@ -116,7 +116,7 @@ unit-test
     1 1.0 2.5 try-breaking-dispatch "bye" = [ 3.5 = ] dip and ;
 
 [ t ] [
-    10000000 [ drop try-breaking-dispatch-2 ] all?
+    10000000 [ drop try-breaking-dispatch-2 ] all-integers?
 ] unit-test
 
 ! Regression
@@ -314,7 +314,7 @@ cell 4 = [
 
 ! Bug with ##return node construction
 : return-recursive-bug ( nodes -- ? )
-    { fixnum } declare [
+    { fixnum } declare iota [
         dup 3 bitand 1 = [ drop t ] [
             dup 3 bitand 2 = [
                 return-recursive-bug
index 37b3a75071f243dfe1105252ab7bee0d4e031c58..0ec84eb9915a72a304eaa484d43f960d816c1171 100644 (file)
@@ -337,7 +337,7 @@ ERROR: bug-in-fixnum* x y a b ;
 
 [ ] [
     10000 [
-        5 random [ drop 32 random-bits ] map product >bignum
+        5 iota random iota [ drop 32 random-bits ] map product >bignum
         dup [ bignum>fixnum ] keep compiled-bignum>fixnum =
         [ drop ] [ "Oops" throw ] if
     ] times
index 04064e442758dbd0a26fb4d50abed22c002b186a..865cd639a356583633aa93018d5eac11356a63b2 100644 (file)
@@ -90,7 +90,7 @@ TUPLE: pred-test ;
 : double-label-2 ( a -- b )
     dup array? [ ] [ ] if 0 t double-label-1 ;
 
-[ 0 ] [ 10 double-label-2 ] unit-test
+[ 0 ] [ 10 iota double-label-2 ] unit-test
 
 ! regression
 GENERIC: void-generic ( obj -- * )
@@ -208,7 +208,7 @@ USE: binary-search.private
     ] if ; inline recursive
 
 [ 10 ] [
-    10 20 >vector <flat-slice>
+    10 20 iota <flat-slice>
     [ [ - ] swap old-binsearch ] compile-call 2nip
 ] unit-test
 
@@ -349,7 +349,7 @@ TUPLE: some-tuple x ;
 [ 5 ] [ { 1 2 { 3 { 4 5 } } } deep-find-test ] unit-test
 [ f ] [ { 1 2 { 3 { 4 } } } deep-find-test ] unit-test
 
-[ B{ 0 1 2 3 4 5 6 7 } ] [ [ 8 [ ] B{ } map-as ] compile-call ] unit-test
+[ B{ 0 1 2 3 4 5 6 7 } ] [ [ 8 iota [ ] B{ } map-as ] compile-call ] unit-test
 
 [ 0 ] [ 1234 [ { fixnum } declare -64 shift ] compile-call ] unit-test
 
index db960863717aa28fffa3234d874ec2860f3da710..05f9092ee130fe95ee6e3f72e607fabc95beaed5 100644 (file)
@@ -339,28 +339,23 @@ cell-bits 32 = [
 ] unit-test
 
 [ t ] [
-    [ { fixnum } declare length [ drop ] each-integer ]
+    [ { fixnum } declare iota [ drop ] each ]
     { < <-integer-fixnum +-integer-fixnum + } inlined?
 ] unit-test
 
 [ t ] [
-    [ { fixnum } declare [ drop ] each ]
-    { < <-integer-fixnum +-integer-fixnum + } inlined?
-] unit-test
-
-[ t ] [
-    [ { fixnum } declare 0 [ + ] reduce ]
+    [ { fixnum } declare iota 0 [ + ] reduce ]
     { < <-integer-fixnum nth-unsafe } inlined?
 ] unit-test
 
 [ f ] [
-    [ { fixnum } declare 0 [ + ] reduce ]
+    [ { fixnum } declare iota 0 [ + ] reduce ]
     \ +-integer-fixnum inlined?
 ] unit-test
 
 [ f ] [
     [
-        { integer } declare [ ] map
+        { integer } declare iota [ ] map
     ] \ >fixnum inlined?
 ] unit-test
 
@@ -403,7 +398,7 @@ cell-bits 32 = [
 
 [ t ] [
     [
-        { integer } declare [ 0 >= ] map
+        { integer } declare iota [ 0 >= ] map
     ] { >= fixnum>= } inlined?
 ] unit-test
 
index 6cef45a9c91767ab64577697f9e6f51bf9d61c52..d1fdf6359a19322c472b5422b4c7365105487a2c 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: sequences namespaces kernel accessors assocs sets fry
 arrays combinators columns stack-checker.backend
@@ -36,7 +36,7 @@ M: #branch remove-dead-code*
 
 : drop-indexed-values ( values indices -- node )
     [ drop filter-live ] [ swap nths ] 2bi
-    [ make-values ] keep
+    [ length make-values ] keep
     [ drop ] [ zip ] 2bi
     #data-shuffle ;
 
index 482d370947bb626a601c217fc42689edd9ee5f8b..0c9464374a6edae178674a1494a32b523991fc83 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs sequences kernel locals fry
 combinators stack-checker.backend
@@ -24,7 +24,7 @@ M: #call-recursive compute-live-values*
 
 :: drop-dead-inputs ( inputs outputs -- #shuffle )
     inputs filter-live
-    outputs inputs filter-corresponding make-values
+    outputs inputs filter-corresponding length make-values
     outputs
     inputs
     drop-values ;
@@ -39,7 +39,7 @@ M: #enter-recursive remove-dead-code*
     2bi ;
 
 :: (drop-call-recursive-outputs) ( inputs outputs -- #shuffle )
-    inputs outputs filter-corresponding make-values :> new-live-outputs
+    inputs outputs filter-corresponding length make-values :> new-live-outputs
     outputs filter-live :> live-outputs
     new-live-outputs
     live-outputs
index bb0025caf48e306a8fc36d3feaa0922aaf35e425..77523568d70f6ecc2f6838e515e392359218ef2d 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors words assocs sequences arrays namespaces
 fry locals definitions classes classes.algebra generic
@@ -67,7 +67,7 @@ M: #alien-node compute-live-values* nip look-at-inputs ;
     filter-corresponding zip #data-shuffle ; inline
 
 :: drop-dead-values ( outputs -- #shuffle )
-    outputs make-values :> new-outputs
+    outputs length make-values :> new-outputs
     outputs filter-live :> live-outputs
     new-outputs
     live-outputs
index 62fc9cdb82d12038b249f8d53e1cc944bc63d895..47ec13e809b4eb9f3084c6bb145b4dafc76f0e31 100644 (file)
@@ -64,7 +64,7 @@ TUPLE: shuffle-node { effect effect } ;
 M: shuffle-node pprint* effect>> effect>string text ;
  
 : (shuffle-effect) ( in out #shuffle -- effect )
-    mapping>> '[ _ at ] map <effect> ;
+    mapping>> '[ _ at ] map [ >array ] bi@ <effect> ;
 
 : shuffle-effect ( #shuffle -- effect )
     [ in-d>> ] [ out-d>> ] [ ] tri (shuffle-effect) ;
index c26f3ddefc02a26a7f779ed1c69aea5829d04649..bb32e6e23b1a229cee60d336cacfcad359547a88 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel tools.test namespaces sequences
+USING: kernel tools.test namespaces sequences math
 compiler.tree.escape-analysis.recursive
 compiler.tree.escape-analysis.allocations ;
 IN: compiler.tree.escape-analysis.recursive.tests
@@ -6,7 +6,7 @@ IN: compiler.tree.escape-analysis.recursive.tests
 H{ } clone allocations set
 <escaping-values> escaping-values set
 
-[ ] [ 8 [ introduce-value ] each ] unit-test
+[ ] [ 8 [ introduce-value ] each-integer ] unit-test
 
 [ ] [ { 1 2 } 3 record-allocation ] unit-test
 
index 42e7f421bfc04073ae014c6abd8d45aa6e931840..7366a83ee176f34df1920eb20c02556d89b7b6ba 100644 (file)
@@ -73,7 +73,7 @@ TUPLE: declared-fixnum { x fixnum } ;
 
 [ t ] [
     [
-        { fixnum } declare 0 swap
+        { fixnum } declare iota 0 swap
         [
             drop 615949 * 797807 + 20 2^ rem dup 19 2^ -
         ] map
@@ -94,7 +94,7 @@ TUPLE: declared-fixnum { x fixnum } ;
 
 [ t ] [
     [
-        { integer } declare [ 256 mod ] map
+        { integer } declare iota [ 256 mod ] map
     ] { mod fixnum-mod } inlined?
 ] unit-test
 
index fcfa42c70ba56388420cc896a217edd4c753c897..7912fce1f68d2c59256aef72c2b963e3da829467 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry namespaces sequences math math.order accessors kernel arrays
 combinators assocs
@@ -75,10 +75,9 @@ M: #phi normalize*
     ] with-variable ;
 
 M: #recursive normalize*
-    dup label>> introductions>>
-    [ drop [ child>> first ] [ in-d>> ] bi >>in-d drop ]
-    [ make-values '[ _ (normalize) ] change-child ]
-    2bi ;
+    [ [ child>> first ] [ in-d>> ] bi >>in-d drop ]
+    [ dup label>> introductions>> make-values '[ _ (normalize) ] change-child ]
+    bi ;
 
 M: #enter-recursive normalize*
     [ introduction-stack get prepend ] change-out-d
index ff4886d1c795ad0ecc2fb7d7dbe0d246f9474871..439b428784e3cb92c3d02bbb42c6d2f506bf6434 100644 (file)
@@ -1,8 +1,8 @@
-! Copyright (C) 2009 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2009, 2010 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators combinators.private effects fry
-kernel kernel.private make sequences continuations quotations
-words math stack-checker combinators.short-circuit
+USING: accessors arrays combinators combinators.private effects
+fry kernel kernel.private make sequences continuations
+quotations words math stack-checker combinators.short-circuit
 stack-checker.transforms compiler.tree.propagation.info
 compiler.tree.propagation.inlining compiler.units ;
 IN: compiler.tree.propagation.call-effect
@@ -43,7 +43,7 @@ M: +unknown+ curry-effect ;
 M: effect curry-effect
     [ in>> length ] [ out>> length ] [ terminated?>> ] tri
     pick 0 = [ [ 1 + ] dip ] [ [ 1 - ] 2dip ] if
-    effect boa ;
+    [ [ "x" <array> ] bi@ ] dip effect boa ;
 
 M: curry cached-effect
     quot>> cached-effect curry-effect ;
index 826131ab612525013b49a2c37c14488d238bbafe..446aad89e5cf224dab4e3e95cc260841c3b19946 100644 (file)
@@ -4,13 +4,6 @@ IN: compiler.tree.propagation.info.tests
 
 [ f ] [ 0.0 -0.0 eql? ] unit-test
 
-[ t ] [
-    number <class-info>
-    sequence <class-info>
-    value-info-intersect
-    class>> integer class=
-] unit-test
-
 [ t t ] [
     0 10 [a,b] <interval-info>
     5 20 [a,b] <interval-info>
index 9be76ba0d03f646378243f123c83c0d8bf2e8602..2c80b87e76096ec0d79143946baaba672f9fc72a 100644 (file)
@@ -406,14 +406,6 @@ IN: compiler.tree.propagation.tests
     ] final-literals
 ] unit-test
 
-[ V{ 27 } ] [
-    [
-        dup number? over sequence? and [
-            dup 10 < over 8 <= not and [ 3 * ] [ "A" throw ] if
-        ] [ "B" throw ] if
-    ] final-literals
-] unit-test
-
 [ V{ string string } ] [
     [
         2dup [ dup string? [ "Oops" throw ] unless ] bi@ 2drop
@@ -681,7 +673,7 @@ M: array iterate first t ; inline
 ] unit-test
 
 [ V{ fixnum } ] [
-    [ { fixnum fixnum } declare [ nth-unsafe ] curry call ] final-classes
+    [ { fixnum fixnum } declare iota [ nth-unsafe ] curry call ] final-classes
 ] unit-test
 
 [ V{ f } ] [
index 9475b5df4aaa9896a4788fee69dcd7dbe492280d..225f10d342ef55b729d37b70cf9b0d486aed2e04 100644 (file)
@@ -80,7 +80,7 @@ M: #declare propagate-before
 : (fold-call) ( #call word -- info )
     [ [ out-d>> ] [ in-d>> [ value-info literal>> ] map ] bi ] [ '[ _ execute ] ] bi*
     '[ _ _ with-datastack [ <literal-info> ] map nip ]
-    [ drop [ object-info ] replicate ]
+    [ drop length [ object-info ] replicate ]
     recover ;
 
 : fold-call ( #call word -- )
index f88b60d338f7470c8dfcd26966fc624909795b98..63c0aea13ebf931dd8e197be625e6dd0c5f6f434 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2008, 2010 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types kernel sequences words fry generic accessors
 classes.tuple classes classes.algebra definitions
@@ -189,7 +189,7 @@ ERROR: bad-partial-eval quot word ;
 \ index [
     dup sequence? [
         dup length 4 >= [
-            dup length zip >hashtable '[ _ at ]
+            dup length iota zip >hashtable '[ _ at ]
         ] [ drop f ] if
     ] [ drop f ] if
 ] 1 define-partial-eval
@@ -228,7 +228,7 @@ CONSTANT: lookup-table-at-max 256
     } 1&& ;
 
 : lookup-table-seq ( assoc -- table )
-    [ keys supremum 1 + ] keep '[ _ at ] { } map-as ;
+    [ keys supremum 1 + iota ] keep '[ _ at ] { } map-as ;
 
 : lookup-table-quot ( seq -- newquot )
     lookup-table-seq
index 567c435c2e05486e97378c1d7852c149d69e58e2..d0bc9d61dc7994096141383df05abba2bef12a09 100644 (file)
@@ -36,7 +36,7 @@ CONSTANT: clen-shuffle { 16 17 18 0 8 7 9 6 10 5 11 4 12 3 13 2 14 1 15 }
     5 bitstream bs:read 1 +
     4 bitstream bs:read 4 + clen-shuffle swap head 
 
-    dup length iota [ 3 bitstream bs:read ] replicate
+    dup length [ 3 bitstream bs:read ] replicate
     get-table
     bitstream swap <huffman-decoder>
     [ 2dup + ] dip swap :> k!
@@ -64,12 +64,12 @@ CONSTANT: clen-shuffle { 16 17 18 0 8 7 9 6 10 5 11 4 12 3 13 2 14 1 15 }
 
 MEMO: static-huffman-tables ( -- obj )
     [
-        0 143 [a,b] [ 8 ] replicate
-        144 255 [a,b] [ 9 ] replicate append
-        256 279 [a,b] [ 7 ] replicate append
-        280 287 [a,b] [ 8 ] replicate append
+        0 143 [a,b] length [ 8 ] replicate
+        144 255 [a,b] length [ 9 ] replicate append
+        256 279 [a,b] length [ 7 ] replicate append
+        280 287 [a,b] length [ 8 ] replicate append
     ] append-outputs
-    0 31 [a,b] [ 5 ] replicate 2array
+    0 31 [a,b] length [ 5 ] replicate 2array
     [ [ length>> [0,b) ] [ ] bi get-table ] map ;
 
 CONSTANT: length-table
index d3f3229171bb279522c8d01d0e6c869d62a00077..57a679f240dd6fa7840dcc6ad64b2ae3a7a2a221 100644 (file)
@@ -11,18 +11,18 @@ IN: concurrency.combinators.tests
 \r
 [ { 1 4 9 } ] [ { 1 2 3 } [ sq ] parallel-map ] unit-test\r
 \r
-[ { 1 4 9 } ] [ { 1 2 3 } [ 1000000 random sleep sq ] parallel-map ] unit-test\r
+[ { 1 4 9 } ] [ { 1 2 3 } [ 1000000 iota random sleep sq ] parallel-map ] unit-test\r
 \r
 [ { 1 2 3 } [ dup 2 mod 0 = [ "Even" throw ] when ] parallel-map ]\r
 [ error>> "Even" = ] must-fail-with\r
 \r
 [ V{ 0 3 6 9 } ]\r
-[ 10 [ 3 mod zero? ] parallel-filter ] unit-test\r
+[ 10 iota [ 3 mod zero? ] parallel-filter ] unit-test\r
 \r
 [ 10 ]\r
 [\r
     V{ } clone\r
-    10 over [ push ] curry parallel-each\r
+    10 iota over [ push ] curry parallel-each\r
     length\r
 ] unit-test\r
 \r
@@ -41,7 +41,7 @@ IN: concurrency.combinators.tests
 [ 20 ]\r
 [\r
     V{ } clone\r
-    10 10 pick [ [ push ] [ push ] bi ] curry 2parallel-each\r
+    10 iota 10 iota pick [ [ push ] [ push ] bi ] curry 2parallel-each\r
     length\r
 ] unit-test\r
 \r
index bd523b38e6d81a887ab9f3db2ce5e9653b50e0c3..f26729f8eae2a955293ce661752126281d87501c 100644 (file)
@@ -100,10 +100,10 @@ M: object execute-statement* ( statement type -- )
     t >>bound? drop ;
 
 : sql-row ( result-set -- seq )
-    dup #columns [ row-column ] with map ;
+    dup #columns [ row-column ] with { } map-integers ;
 
 : sql-row-typed ( result-set -- seq )
-    dup #columns [ row-column-typed ] with map ;
+    dup #columns [ row-column-typed ] with { } map-integers ;
 
 : query-each ( statement quot: ( statement -- ) -- )
     over more-rows? [
index e9aa01feb4bb9568486c4a9b37268c247664311d..3ff93f49c67f42f461159c6446fa7b6c91f36453 100644 (file)
@@ -34,7 +34,7 @@ SINGLETON: retryable
     ] 2map >>bind-params ;
     
 M: retryable execute-statement* ( statement type -- )
-    drop [ retries>> ] [
+    drop [ retries>> iota ] [
         [
             nip
             [ query-results dispose t ]
index 19140259bf1e4b913a4243f8b7abd81ab99b0254..1949ab42cc37f6e3178c9ec00f1bc18a20fa0795 100644 (file)
@@ -57,7 +57,7 @@ test-2 "TEST2" {
 } define-persistent
 
 : test-1-tuple ( -- tuple )
-    f 100 random 100 random 100 random [ number>string ] tri@
+    f 100 iota random 100 iota random 100 iota random [ number>string ] tri@
     test-1 boa ;
 
 : db-tester ( test-db -- )
@@ -67,7 +67,7 @@ test-2 "TEST2" {
             test-2 ensure-table
         ] with-db
     ] [
-        10 [
+        10 iota [
             drop
             10 [
                 dup [
@@ -85,7 +85,7 @@ test-2 "TEST2" {
         ] with-db
     ] [
         <db-pool> [
-            10 [
+            10 iota [
                 10 [
                     test-1-tuple insert-tuple yield
                 ] times
index 863dc522b2d694de12c3b3cc30ab095b24aa914b..e967250b230c848bd0007cfed79df861e875fc4c 100644 (file)
@@ -186,7 +186,7 @@ link-no-follow? off
 
 : random-markup ( -- string )
     10 [
-        2 random 1 = [
+        2 iota random 1 = [
             {
                 "[["
                 "*"
@@ -205,7 +205,7 @@ link-no-follow? off
     100 [
         drop random-markup
         [ convert-farkup drop t ] [ drop print f ] recover
-    ] all?
+    ] all-integers?
 ] unit-test
 
 [ "<p><a href=\"http://foo.com/~foo\">http://foo.com/~foo</a></p>" ] [ "[[http://foo.com/~foo]]" convert-farkup ] unit-test
index f33eb276a0e88f6320ff920865811e7321ac352e..b341c462be39afe739f41d64a4298a4204a8e794 100644 (file)
@@ -64,7 +64,7 @@ SYMBOLS: a b c d e f g h ;
 [ "hi" 3 ] [ "h" "i" 3 [ append ] funny-dip ] unit-test
 
 [ { 1 2 3 } ] [
-    3 1 '[ _ [ _ + ] map ] call
+    3 1 '[ _ iota [ _ + ] map ] call
 ] unit-test
 
 [ { 1 { 2 { 3 } } } ] [
index 546413447e6a28fc1b385ec1f43af84c12fccc11..0c35f157142419ed6b1e912c6fe23707a950d3b8 100644 (file)
@@ -64,7 +64,7 @@ IN: generalizations.tests
 { 3 5 } [ 2 nweave ] must-infer-as\r
 \r
 [ { 0 1 2 } { 3 5 4 } { 7 8 6 } ]\r
-[ 9 [ ] each { [ 3array ] [ swap 3array ] [ rot 3array ] } 3 nspread ] unit-test\r
+[ 9 [ ] each-integer { [ 3array ] [ swap 3array ] [ rot 3array ] } 3 nspread ] unit-test\r
 \r
 [ 1 2 3 4 1 2 3 ] [ 1 2 3 4 3 nover ] unit-test\r
 \r
index c1985c516f995cdee7c614985f4e9330a4b7c36e..703cf530805c06b44fbb6552847a12743c7d3d04 100644 (file)
@@ -31,7 +31,7 @@ IN: heaps.tests
     <min-heap> [ heap-push-all ] keep heap-pop-all ;
 
 : random-alist ( n -- alist )
-    [
+    iota [
         drop 32 random-bits dup number>string
     ] H{ } map>assoc ;
 
@@ -40,16 +40,16 @@ IN: heaps.tests
 
 14 [
     [ t ] swap [ 2^ test-heap-sort ] curry unit-test
-] each
+] each-integer
 
 : test-entry-indices ( n -- ? )
     random-alist
     <min-heap> [ heap-push-all ] keep
-    data>> dup length swap [ index>> ] map sequence= ;
+    data>> dup length iota swap [ index>> ] map sequence= ;
 
 14 [
     [ t ] swap [ 2^ test-entry-indices ] curry unit-test
-] each
+] each-integer
 
 : sort-entries ( entries -- entries' )
     [ key>> ] sort-with ;
@@ -66,4 +66,4 @@ IN: heaps.tests
 
 11 [
     [ t ] swap [ 2^ delete-test sequence= ] curry unit-test
-] each
+] each-integer
index 1ca5bf1bc54ff898a1fec4d11b8c5be848f463cc..e4bbb3459e53a3b6543573666bde13843b7b8046 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs byte-arrays byte-vectors classes
 combinators definitions effects fry generic generic.single
@@ -24,7 +24,7 @@ M: object specializer-declaration class ;
     "specializer" word-prop ;
 
 : make-specializer ( specs -- quot )
-    dup length <reversed>
+    dup length iota <reversed>
     [ (picker) 2array ] 2map
     [ drop object eq? not ] assoc-filter
     [ [ t ] ] [
index 82c2487f671b30bacb8af47767b6da887e2e7a7e..2aa7cd218e02b051ca1ac66b2612bbefe620b2d1 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays generic hashtables io kernel assocs math
 namespaces prettyprint prettyprint.custom prettyprint.sections
@@ -23,9 +23,7 @@ GENERIC: add-numbers ( alist -- table' )
 M: enum add-numbers ;
 
 M: assoc add-numbers
-    +number-rows+ get [
-        dup length [ prefix ] 2map
-    ] when ;
+    +number-rows+ get [ [ prefix ] map-index ] when ;
 
 TUPLE: slot-name name ;
 
index 4ecb1e12a8a133e52f4db1bcd845bbf154927f6b..383a4aca9bc3a95d52cda9fb88eb840b08ce4f37 100644 (file)
@@ -68,7 +68,7 @@ UNION: explicit-inverse normal-inverse math-inverse pop-inverse ;
 
 : enough? ( stack word -- ? )
     dup deferred? [ 2drop f ] [
-        [ [ length ] [ 1quotation infer in>> ] bi* >= ]
+        [ [ length ] [ 1quotation infer in>> length ] bi* >= ]
         [ 3drop f ] recover
     ] if ;
 
@@ -273,10 +273,10 @@ DEFER: __
     ] recover ; inline
 
 : true-out ( quot effect -- quot' )
-    out>> '[ @ _ ndrop t ] ;
+    out>> length '[ @ _ ndrop t ] ;
 
 : false-recover ( effect -- quot )
-    in>> [ ndrop f ] curry [ recover-fail ] curry ;
+    in>> length [ ndrop f ] curry [ recover-fail ] curry ;
 
 : [matches?] ( quot -- undoes?-quot )
     [undo] dup infer [ true-out ] [ false-recover ] bi curry ;
index 17264267777486fc000ae91e6d7bd5daa0e7744b..7d4d7f1215f6fa89b43fd118c1e9d68faa238d6b 100644 (file)
@@ -18,7 +18,7 @@ VALUE: jis212
 "vocab:io/encodings/iso2022/212.txt" flat-file>biassoc to: jis212
 
 VALUE: ascii
-128 unique >biassoc to: ascii
+128 iota unique >biassoc to: ascii
 
 TUPLE: iso2022-state type ;
 
index ef7d778abe7ae439b2ce4c35e6a81bc66b92b15c..23de95f519c591a9c83147d45b6e88e811e2905b 100644 (file)
@@ -4,7 +4,7 @@ io.pathnames namespaces ;
 IN: io.files.links.unix.tests
 
 : make-test-links ( n path -- )
-    [ '[ [ 1 + ] keep [ number>string _ prepend ] bi@ make-link ] each ]
+    [ '[ [ 1 + ] keep [ number>string _ prepend ] bi@ make-link ] each-integer ]
     [ [ number>string ] dip prepend touch-file ] 2bi ; inline
 
 [ t ] [
index f167b1e99ba32f387a454e03f379fe662c71ddde..6a00ee523b91ae31619c17315ff51a3187cc3023 100644 (file)
@@ -26,17 +26,17 @@ SYMBOL: unique-retries
 <PRIVATE
 
 : random-letter ( -- ch )
-    26 random { CHAR: a CHAR: A } random + ;
+    26 iota random { CHAR: a CHAR: A } random + ;
 
 : random-ch ( -- ch )
     { t f } random
-    [ 10 random CHAR: 0 + ] [ random-letter ] if ;
+    [ 10 iota random CHAR: 0 + ] [ random-letter ] if ;
 
 : random-name ( -- string )
     unique-length get [ random-ch ] "" replicate-as ;
 
-: retry ( quot: ( -- ? )  n -- )
-    swap [ drop ] prepose attempt-all ; inline
+: retry ( quot: ( -- ? ) n -- )
+    iota swap [ drop ] prepose attempt-all ; inline
 
 : (make-unique-file) ( path prefix suffix -- path )
     '[
index 0c2ed34f453b99958081ada4476fc5592c23d30e..2ee662c0ac5698fb2c65bcb80d4fa81cee53ee16 100644 (file)
@@ -3,4 +3,4 @@
 USING: lcs.diff2html lcs kernel tools.test strings sequences xml.writer ;
 IN: lcs.diff2html.tests
 
-[ ] [ "hello" "heyo" [ 1string ] { } map-as diff htmlize-diff xml>string drop ] unit-test
+[ ] [ "hello" "heyo" [ [ 1string ] { } map-as ] bi@ diff htmlize-diff xml>string drop ] unit-test
index ca9e48eb057623509324bba81db54a788ff0baeb..545610a0ea2a90c66bb7b521982fba57483f5811 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov
+! Copyright (C) 2008, 2010 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: lcs xml.syntax xml.writer kernel strings ;
 FROM: accessors => item>> ;
index 38920f5764669daffbb2d6f07602de6dca37b27f..5861d90dc377492cff651147e6af2a8f65957aa8 100644 (file)
@@ -19,15 +19,15 @@ IN: lcs
     i 1 + j 1 + matrix nth set-nth ; inline\r
 \r
 : lcs-initialize ( |str1| |str2| -- matrix )\r
-    [ drop 0 <array> ] with map ;\r
+    iota [ drop 0 <array> ] with map ;\r
 \r
 : levenshtein-initialize ( |str1| |str2| -- matrix )\r
-    [ [ + ] curry map ] with map ;\r
+    [ iota ] bi@ [ [ + ] curry map ] with map ;\r
 \r
 :: run-lcs ( old new init step -- matrix )\r
     old length 1 + new length 1 + init call :> matrix\r
-    old length [| i |\r
-        new length\r
+    old length iota [| i |\r
+        new length iota\r
         [| j | i j matrix old new step loop-step ] each\r
     ] each matrix ; inline\r
 PRIVATE>\r
index 25f754e92af46ca874d2ed42f67f13d978cac1cf..3dab0c3cdb12a25a299b5aa0714356a178a44ca3 100644 (file)
@@ -49,7 +49,7 @@ M: wrapper expand-macros* wrapped>> literal ;
     stack get pop end
     [ [ expand-macros ] [ ] map-as '[ _ dip ] % ]
     [
-        length [ <reversed> ] keep
+        length iota [ <reversed> ] keep
         [ '[ _ ndrop _ nnip call ] [ ] like ] 2map , \ dispatch ,
     ] bi ;
 
index ca6ec9cb53c02d0d5722d8bf70eae70bfd3cd4b9..bbf5a1cb85bfaa08a35f581ae18faeb1288fe959 100644 (file)
@@ -56,7 +56,7 @@ IN: math.combinatorics.tests
 [ 0 ] [ 9 5 iota 3 <combo> dual-index ] unit-test
 [ 179 ] [ 72 10 iota 5 <combo> dual-index ] unit-test
 
-[ { 5 3 2 1 } ] [ 7 4 <combo> 8 combinadic ] unit-test
+[ { 5 3 2 1 } ] [ 7 iota 4 <combo> 8 combinadic ] unit-test
 [ { 4 3 2 1 0 } ] [ 10 iota 5 <combo> 0 combinadic ] unit-test
 [ { 8 6 3 1 0 } ] [ 10 iota 5 <combo> 72 combinadic ] unit-test
 [ { 9 8 7 6 5 } ] [ 10 iota 5 <combo> 251 combinadic ] unit-test
index 36b62ddcc06d0cbe53417a81d50a8a5714433af3..32f9ae1db358fd9b062e649fabee81de79cfa556 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (c) 2007-2009 Slava Pestov, Doug Coleman, Aaron Schaefer.
+! Copyright (c) 2007-2010 Slava Pestov, Doug Coleman, Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs binary-search fry kernel locals math math.order
     math.ranges namespaces sequences sorting ;
@@ -15,7 +15,7 @@ IN: math.combinatorics
 PRIVATE>
 
 : factorial ( n -- n! )
-    1 [ 1 + * ] reduce ;
+    iota 1 [ 1 + * ] reduce ;
 
 : nPk ( n k -- nPk )
     2dup possible? [ dupd - [a,b) product ] [ 2drop 0 ] if ;
@@ -46,11 +46,11 @@ PRIVATE>
     [ permutation-indices ] keep nths ;
 
 : all-permutations ( seq -- seq )
-    [ length factorial ] keep
+    [ length factorial iota ] keep
     '[ _ permutation ] map ;
 
 : each-permutation ( seq quot -- )
-    [ [ length factorial ] keep ] dip
+    [ [ length factorial iota ] keep ] dip
     '[ _ permutation @ ] each ; inline
 
 : reduce-permutations ( seq identity quot -- result )
index a569b4af7bb39b852c752d83c85d5c83f48466b0..e38182bf9d896d671219158c3a21db9c3f77b5d8 100644 (file)
@@ -250,7 +250,7 @@ IN: math.intervals.tests
     dup full-interval eq? [
         drop 32 random-bits 31 2^ -
     ] [
-        [ ] [ from>> first ] [ to>> first ] tri over - random +
+        [ ] [ from>> first ] [ to>> first ] tri over - iota random +
         2dup swap interval-contains? [
             nip
         ] [
@@ -259,10 +259,10 @@ IN: math.intervals.tests
     ] if ;
 
 : random-interval ( -- interval )
-    10 random 0 = [ full-interval ] [
-        2000 random 1000 - dup 2 1000 random + +
-        1 random zero? [ [ neg ] bi@ swap ] when
-        4 random {
+    10 iota random 0 = [ full-interval ] [
+        2000 iota random 1000 - dup 2 1000 iota random + +
+        1 iota random zero? [ [ neg ] bi@ swap ] when
+        4 iota random {
             { 0 [ [a,b] ] }
             { 1 [ [a,b) ] }
             { 2 [ (a,b) ] }
@@ -291,7 +291,7 @@ IN: math.intervals.tests
     ] if ;
 
 unary-ops [
-    [ [ t ] ] dip '[ 8000 iota [ drop _ unary-test ] all? ] unit-test
+    [ [ t ] ] dip '[ 8000 [ drop _ unary-test ] all-integers? ] unit-test
 ] each
 
 : binary-ops ( -- alist )
@@ -366,7 +366,7 @@ comparison-ops [
 
 ! Test that commutative interval ops really are
 : random-interval-or-empty ( -- obj )
-    10 random 0 = [ empty-interval ] [ random-interval ] if ;
+    10 iota random 0 = [ empty-interval ] [ random-interval ] if ;
 
 : commutative-ops ( -- seq )
     {
index 371eb8a36c092bb4152e25eb71f3cbe84265c766..c8d5bb7338ea377811611437316fabe780872b1b 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2006, 2008 Slava Pestov.
+! Copyright (C) 2006, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel locals math math.vectors math.matrices
 namespaces sequences fry sorting ;
@@ -42,7 +42,7 @@ SYMBOL: matrix
     [ [ clear-scale ] 2keep [ n*v ] dip v+ ] change-row ;
 
 : rows-from ( row# -- slice )
-    rows dup <slice> ;
+    rows dup iota <slice> ;
 
 : clear-col ( col# row# rows -- )
     [ nth-row ] dip [ [ 2dup ] dip (clear-col) ] each 2drop ;
@@ -79,9 +79,9 @@ SYMBOL: matrix
 
 : reduced ( matrix' -- matrix'' )
     [
-        rows <reversed> [
+        rows iota <reversed> [
             dup nth-row leading drop
-            dup [ swap dup clear-col ] [ 2drop ] if
+            dup [ swap dup iota clear-col ] [ 2drop ] if
         ] each
     ] with-matrix ;
 
index 75b9be5caec547429b2ff10422bf45dafa9c6e97..bf14d7ba13ccff4bcf5eb55385f561a5543c0e3b 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2009 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov, Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays columns kernel locals math math.bits
 math.functions math.order math.vectors sequences
@@ -11,7 +11,7 @@ IN: math.matrices
 
 : identity-matrix ( n -- matrix )
     #! Make a nxn identity matrix.
-    dup [ [ = 1 0 ? ] with map ] curry map ;
+    iota dup [ [ = 1 0 ? ] with map ] curry map ;
 
 :: rotation-matrix3 ( axis theta -- matrix )
     theta cos :> c
index 0de18b6febc38320a9acc305edcf16681daa7036..99d77d0ce2216d66d66bad92c36592b69833f293 100644 (file)
@@ -32,7 +32,7 @@ PRIVATE>
     2dup [ length ] bi@ + 1 - 2pad-tail [ >vector ] bi@ ;
 
 : p* ( p q -- r )
-    2unempty pextend-conv <reversed> dup length
+    2unempty pextend-conv <reversed> dup length iota
     [ over length pick <slice> pick [ * ] 2map sum ] map 2nip reverse ;
 
 : p-sq ( p -- p^2 )
index d201abfef8f5705dbaa25320014cf187d79da6b4..f803b7db01aebdee0ba41f1c0edf71705a908637 100644 (file)
@@ -8,4 +8,4 @@ IN: math.primes.miller-rabin.tests
 [ t ] [ 37 miller-rabin ] unit-test
 [ t ] [ 2135623355842621559 miller-rabin ] unit-test
 
-[ f ] [ 1000 [ drop 15 miller-rabin ] any? ] unit-test
+[ f ] [ 1000 iota [ drop 15 miller-rabin ] any? ] unit-test
index 04b1330cc2e0bec710355bf32b387d812a28fa5f..ac5c2df705764a6003c5d360bd4e519c3043a482 100644 (file)
@@ -10,7 +10,7 @@ IN: math.primes.miller-rabin
     n 1 - :> n-1
     n-1 factor-2s :> ( r s )
     0 :> a!
-    trials [
+    trials iota [
         drop
         2 n 2 - [a,b] random a!
         a s n ^mod 1 = [
index 81193af400bfa749003a2b01b831b5e9dfb059c3..19dcc6aeaf2dff7e89997e0d7d3a1a4c38e367de 100644 (file)
@@ -78,7 +78,7 @@ PRIVATE>
     >odd (find-relative-prime) ;
 
 : find-relative-prime ( n -- p )
-    dup random find-relative-prime* ;
+    dup iota random find-relative-prime* ;
 
 ERROR: too-few-primes n numbits ;
 
index e099f6e830523ffc147910f61e1839a4692031e5..815b34a90d7288b816ce0cf9dc37bcba81df7a1d 100644 (file)
@@ -22,7 +22,7 @@ A-cast DEFINES       ${A}-cast
 A{     DEFINES       ${A}{
 
 N       [ A-rep rep-length ]
-BOA-EFFECT [ N 2 * "n" <repetition> >array { "v" } <effect> ]
+BOA-EFFECT [ N 2 * "n" <array> { "v" } <effect> ]
 
 WHERE
 
index 658d9b270c8eaffe1f6e3ab792ab771a2b05ab38..d80755a6a5c2cb24b37f1c6e5cf142ee0d33096d 100644 (file)
@@ -238,7 +238,7 @@ PRIVATE>
     [ >rep-array ] [ widen-vector-rep [ rep-length ] [ [>rep-array] ] bi ] bi
     [ tail-slice ] dip call( a' -- c' ) underlying>> ;
 : (simd-with)              (   n rep -- v )
-    [ rep-length iota swap '[ _ ] ] [ <rep-array> ] bi replicate-as 
+    [ rep-length swap '[ _ ] ] [ <rep-array> ] bi replicate-as 
     underlying>> ;
 : (simd-gather-2)          ( m n rep -- v ) <rep-array> [ 2 set-firstn ] keep underlying>> ;
 : (simd-gather-4)          ( m n o p rep -- v ) <rep-array> [ 4 set-firstn ] keep underlying>> ;
index aaa55078640749b3135a48489b0e075be1ab1c75..d32ee5d443ed3650d581fcc33bba8f1a20fda471 100644 (file)
@@ -151,7 +151,7 @@ CONSTANT: vector-words
 
 [ { } ] [
     with-ctors [
-        [ 1000 random '[ _ ] ] dip '[ _ execute ]
+        [ 1000 iota random '[ _ ] ] dip '[ _ execute ]
     ] [ = ] check-optimizer
 ] unit-test
 
@@ -165,7 +165,7 @@ CONSTANT: vector-words
 
 [ { } ] [
     boa-ctors [
-        [ stack-effect in>> length [ 1000 random ] [ ] replicate-as ] keep
+        [ stack-effect in>> length [ 1000 iota random ] [ ] replicate-as ] keep
         '[ _ execute ]
     ] [ = ] check-optimizer
 ] unit-test
@@ -175,11 +175,12 @@ CONSTANT: vector-words
 "== Checking vector operations" print
 
 : random-int-vector ( class -- vec )
-    new [ drop 1,000 random ] map ;
+    new [ drop 1000 iota random ] map ;
+
 : random-float-vector ( class -- vec )
     new [
         drop
-        1000 random
+        1000 iota random
         10 swap <array> 0/0. suffix random
     ] map ;
 
@@ -192,7 +193,7 @@ CONSTANT: vector-words
     inputs [
         {
             { +vector+ [ class elt-class random-vector ] }
-            { +scalar+ [ 1000 random elt-class float = [ >float ] when ] }
+            { +scalar+ [ 1000 iota random elt-class float = [ >float ] when ] }
         } case
     ] [ ] map-as
     word '[ _ execute ] ;
@@ -254,13 +255,13 @@ simd-classes&reps [
 "== Checking boolean operations" print
 
 : random-boolean-vector ( class -- vec )
-    new [ drop 2 random zero? ] map ;
+    new [ drop 2 iota random zero? ] map ;
 
 :: check-boolean-op ( word inputs class elt-class -- inputs quot )
     inputs [
         {
             { +vector+ [ class random-boolean-vector ] }
-            { +scalar+ [ 1000 random elt-class float = [ >float ] when ] }
+            { +scalar+ [ 1000 iota random elt-class float = [ >float ] when ] }
         } case
     ] [ ] map-as
     word '[ _ execute ] ;
@@ -371,7 +372,7 @@ simd-classes&reps [
             [ [ 4 + ] map ] map
             [ append ] 2map
         ] }
-        [ dup '[ _ random ] replicate 1array ]
+        [ dup '[ _ iota random ] replicate 1array ]
     } case ;
 
 simd-classes [
@@ -386,7 +387,7 @@ simd-classes [
 "== Checking variable shuffles" print
 
 : random-shift-vector ( class -- vec )
-    new [ drop 16 random ] map ;
+    new [ drop 16 iota random ] map ;
 
 :: test-shift-vector ( class -- ? )
     [
@@ -463,7 +464,7 @@ TUPLE: inconsistent-vector-test bool branch ;
 
 ! Test element access -- it should box bignums for int-4 on x86
 : test-accesses ( seq -- failures )
-    [ length >array ] keep
+    [ length iota >array ] keep
     '[ [ _ 1quotation ] dip '[ _ swap nth ] ] [ = ] check-optimizer ; inline
 
 [ { } ] [ float-4{ 1.0 2.0 3.0 4.0 } test-accesses ] unit-test
@@ -480,7 +481,7 @@ TUPLE: inconsistent-vector-test bool branch ;
 
 "== Checking broadcast" print
 : test-broadcast ( seq -- failures )
-    [ length >array ] keep
+    [ length iota >array ] keep
     '[ [ _ 1quotation ] dip '[ _ vbroadcast ] ] [ = ] check-optimizer ;
 
 [ { } ] [ float-4{ 1.0 2.0 3.0 4.0 } test-broadcast ] unit-test
index 905737c266c283cca9ec43534888cbde7f3931bf..acf13599c1f059552a8671ca323531e09370a7ce 100644 (file)
@@ -247,7 +247,7 @@ COERCER [ ELT c-type-class "coercer" word-prop [ ] or ]
 
 SET-NTH [ ELT dup c:c-setter c:array-accessor ]
 
-BOA-EFFECT [ N "n" <repetition> >array { "v" } <effect> ]
+BOA-EFFECT [ N "n" <array> { "v" } <effect> ]
 
 WHERE
 
index 257a2bb1ea059be27a418b4eb4f72d15c8493f82..c4ad01e52e09d60d64eeed12bc0a1b3a6a2d1bf4 100644 (file)
@@ -1,9 +1,10 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: models.arrow models.product stack-checker accessors fry
-generalizations macros kernel ;
+generalizations combinators.smart combinators.smart.private
+macros kernel ;
 IN: models.arrow.smart
 
 MACRO: <smart-arrow> ( quot -- quot' )
-    [ infer in>> dup ] keep
+    [ inputs dup ] keep
     '[ _ narray <product> [ _ firstn @ ] <arrow> ] ;
\ No newline at end of file
index 2a0eef7227aed299377fd41e4bdd9a473db950ad..363f30678dadefff30c3522fda26915c563ce31d 100644 (file)
@@ -1,6 +1,6 @@
 USING: nibble-arrays tools.test sequences kernel math ;
 IN: nibble-arrays.tests
 
-[ t ] [ 16 dup >nibble-array sequence= ] unit-test
+[ t ] [ 16 iota dup >nibble-array sequence= ] unit-test
 [ N{ 4 2 1 3 } ] [ N{ 3 1 2 4 } reverse ] unit-test
 [ N{ 1 4 9 0 9 4 } ] [ N{ 1 2 3 4 5 6 } [ sq ] map ] unit-test
index 5ddd5f9bf08e04699ac9ce3bdf16b145553b762d..ffc4cb91ad78aa462b4abbf529ac615225179e80 100644 (file)
@@ -446,14 +446,14 @@ M: ebnf-sequence build-locals ( code ast -- code )
     ] [ \r
       [\r
         "FROM: locals => [let :> ; FROM: sequences => nth ; [let " %\r
-          dup length [\r
+          [\r
             over ebnf-var? [\r
               " " % # " over nth :> " %\r
               name>> % \r
             ] [\r
               2drop\r
             ] if\r
-          ] 2each\r
+          ] each-index\r
           " " %\r
           %  \r
           " nip ]" %     \r
index d66fdd0c089eaacd055ef5926006c17123d4267a..da2dd5f2c2208b79278e2ffcc87f0474b21d0970 100644 (file)
@@ -81,7 +81,7 @@ M: hash-0-b hashcode* 2drop 0 ;
 ] unit-test
 
 : random-string ( -- str )
-    1000000 random ; ! [ CHAR: a CHAR: z [a,b] random ] "" replicate-as ;
+    1000000 iota random ; ! [ CHAR: a CHAR: z [a,b] random ] "" replicate-as ;
 
 : random-assocs ( n -- hash phash )
     [ random-string ] replicate
index 95fa70558d0d6ed4feb5d17f8354fdb71074b8cc..fe3365d32297432d5d001a866c112a78706d7ba1 100644 (file)
@@ -18,16 +18,16 @@ vectors math math.order ;
 ] unit-test
 
 { 100 1060 2000 10000 100000 1000000 } [
-    [ t ] swap [ dup >persistent-vector sequence= ] curry unit-test
+    [ t ] swap [ iota dup >persistent-vector sequence= ] curry unit-test
 ] each
 
 [ ] [ 10000 [ 16 random-bits ] PV{ } replicate-as "1" set ] unit-test
 [ ] [ "1" get >vector "2" set ] unit-test
 
 [ t ] [
-    3000 [
+    3000 iota [
         drop
-        16 random-bits 10000 random
+        16 random-bits 10000 iota random
         [ "1" [ new-nth ] change ]
         [ "2" [ new-nth ] change ] 2bi
         "1" get "2" get sequence=
@@ -56,16 +56,16 @@ vectors math math.order ;
 ] unit-test
 
 [ t ] [
-    10000 >persistent-vector 752 [ ppop ] times dup length sequence=
+    10000 iota >persistent-vector 752 [ ppop ] times dup length iota sequence=
 ] unit-test
 
 [ t ] [
-    100 [
+    100 iota [
         drop
-        100 random [
+        100 iota random [
             16 random-bits [ "1" [ ppush ] change ] [ "2" get push ] bi
         ] times
-        100 random "1" get length min [
+        100 iota random "1" get length min [
             "1" [ ppop ] change
             "2" get pop*
         ] times
index 2e1a47b9512d50b75f68667c123483d1a3e84407..e3cb186bf8057f5d45f2a13faf59c4c2cd2f43af 100644 (file)
@@ -33,10 +33,10 @@ IN: porter-stemmer
     ] if ;
 
 : consonant-seq ( str -- n )
-    0 0 rot skip-consonants (consonant-seq) ;
+    [ 0 0 ] dip skip-consonants (consonant-seq) ;
 
 : stem-vowel? ( str -- ? )
-    [ length ] keep [ consonant? ] curry all? not ;
+    [ length iota ] keep [ consonant? ] curry all? not ;
 
 : double-consonant? ( i str -- ? )
     over 1 < [
index 040b6d8f7c23723f365e04e8bc002d56bb364cb7..6f5f61f688ef3ae019c6524e3e4b13099ec5a462 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2003, 2009 Slava Pestov.
+! Copyright (C) 2003, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays generic hashtables io kernel math assocs
 namespaces make sequences strings io.styles vectors words
@@ -309,7 +309,7 @@ SYMBOL: next
 
 : group-flow ( seq -- newseq )
     [
-        dup length [
+        dup length iota [
             2dup 1 - swap ?nth prev set
             2dup 1 + swap ?nth next set
             swap nth dup split-before dup , split-after
index b877af6f79bfd465addaaa700a269298a80faa26..343baeebf4987be45bf614a94984bad26600e183 100644 (file)
@@ -3,12 +3,12 @@ random.mersenne-twister sequences tools.test math.order ;
 IN: random.mersenne-twister.tests
 
 : check-random ( max -- ? )
-    [ random 0 ] keep between? ;
+    [ iota random 0 ] keep between? ;
 
-[ t ] [ 100 [ drop 674 check-random ] all? ] unit-test
+[ t ] [ 100 [ drop 674 check-random ] all-integers? ] unit-test
 
 : randoms ( -- seq )
-    100 [ 100 random ] replicate ;
+    100 [ 100 iota random ] replicate ;
 
 : test-rng ( seed quot -- )
     [ <mersenne-twister> ] dip with-random ; inline
@@ -16,11 +16,11 @@ IN: random.mersenne-twister.tests
 [ f ] [ 1234 [ randoms randoms = ] test-rng ] unit-test
 
 [ 1333075495 ] [
-    0 [ 1000 [ drop random-generator get random-32* drop ] each random-generator get random-32* ] test-rng
+    0 [ 1000 [ drop random-generator get random-32* drop ] each-integer random-generator get random-32* ] test-rng
 ] unit-test
 
 [ 1575309035 ] [
-    0 [ 10000 [ drop random-generator get random-32* drop ] each random-generator get random-32* ] test-rng
+    0 [ 10000 [ drop random-generator get random-32* drop ] each-integer random-generator get random-32* ] test-rng
 ] unit-test
 
 
index 90489d30521940781ef2c29e98c5a86dd9779247..9fd82a30626a10eb6b4b0985eeca45776bc83a62 100644 (file)
@@ -30,8 +30,8 @@ CONSTANT: a uint-array{ 0 HEX: 9908b0df }
 : mt-generate ( mt -- )
     [
         seq>>
-        [ [ n m - ] dip '[ [ m ] dip _ mt[k] ] each ]
-        [ [ m 1 - ] dip '[ [ m n - ] [ n m - + ] bi* _ mt[k] ] each ]
+        [ [ n m - ] dip '[ [ m ] dip _ mt[k] ] each-integer ]
+        [ [ m 1 - ] dip '[ [ m n - ] [ n m - + ] bi* _ mt[k] ] each-integer ]
         bi
     ] [ 0 >>i drop ] bi ; inline
 
@@ -41,7 +41,7 @@ CONSTANT: a uint-array{ 0 HEX: 9908b0df }
 : init-mt-rest ( seq -- )
     n 1 - swap '[
         _ [ init-mt-formula ] [ [ 1 + ] dip set-nth ] 2bi
-    ] each ; inline
+    ] each-integer ; inline
 
 : init-mt-seq ( seed -- seq )
     32 bits n <uint-array>
index 96dc8cc783c9fdf4d48bec12a58da076f439954f..3854996f33f6a7d9b7b940c900268c20828cd4f7 100644 (file)
@@ -11,12 +11,12 @@ IN: random.tests
 [ 2 ] [ V{ 10 20 30 } [ delete-random drop ] keep length ] unit-test
 [ V{ } [ delete-random drop ] keep length ] must-fail
 
-[ t ] [ 10000 [ 0 [ drop 187 random + ] reduce ] keep / 2 * 187 10 ~ ] unit-test
-[ t ] [ 10000 [ 0 [ drop 400 random + ] reduce ] keep / 2 * 400 10 ~ ] unit-test
+[ t ] [ 10000 [ iota 0 [ drop 187 iota random + ] reduce ] keep / 2 * 187 10 ~ ] unit-test
+[ t ] [ 10000 [ iota 0 [ drop 400 iota random + ] reduce ] keep / 2 * 400 10 ~ ] unit-test
 
-[ t ] [ 1000 [ 400 random ] replicate prune length 256 > ] unit-test
+[ t ] [ 1000 [ 400 iota random ] replicate prune length 256 > ] unit-test
 
-[ f ] [ 0 random ] unit-test
+[ f ] [ 0 iota random ] unit-test
 
 [ { } ] [ { } randomize ] unit-test
 [ { 1 } ] [ { 1 } randomize ] unit-test
index fcde135cf887c0fb1af245ef8332f1d634624f91..33b2ded448e53ad803265f0118ccc864c5449a79 100644 (file)
@@ -11,9 +11,7 @@ TUPLE: parts in out ;
     zip [ first ] partition [ values ] bi@ parts boa ;
 
 : powerset-partition ( sequence -- partitions )
-    [ length [ 2^ ] keep ] keep '[
-        _ <bits> _ make-partition
-    ] map rest ;
+    [ length [ 2^ iota ] keep ] keep '[ _ <bits> _ make-partition ] map rest ;
 
 : partition>class ( parts -- class )
     [ out>> [ <not-class> ] map ]
index a645898c034e9838c970e2216795ebb15c7b8b2c..b3c0181ad2399532ec710490898605b1afd1e97e 100644 (file)
@@ -48,7 +48,7 @@ PRIVATE>
 <PRIVATE
 
 MACRO: binary-roman-op ( quot -- quot' )
-    [ infer in>> ] [ ] [ infer out>> ] tri
+    [ infer in>> length ] [ ] [ infer out>> length ] tri
     '[ [ roman> ] _ napply @ [ >roman ] _ napply ] ;
 
 PRIVATE>
@@ -58,8 +58,7 @@ PRIVATE>
 SYNTAX: ROMAN-OP:
     scan-word [ name>> "roman" prepend create-in ] keep
     1quotation '[ _ binary-roman-op ]
-    dup infer [ in>> ] [ out>> ] bi
-    [ "string" <repetition> ] bi@ <effect> define-declared ;
+    dup infer define-declared ;
 
 >>
 
index 6dbc76386d1c4824f9546d3203d041a88e1cdec0..316eab6e5f51d0f8f2a0b7182982a7876b8d5098 100644 (file)
@@ -9,19 +9,19 @@ SPECIALIZED-ARRAY: double
 IN: serialize.tests
 
 : test-serialize-cell ( a -- ? )
-    2^ random dup
+    2^ iota random dup
     binary [ serialize-cell ] with-byte-writer
     binary [ deserialize-cell ] with-byte-reader = ;
 
 [ t ] [
     100 [
         drop
-        40 [        test-serialize-cell ] all?
-         4 [ 40 *   test-serialize-cell ] all?
-         4 [ 400 *  test-serialize-cell ] all?
-         4 [ 4000 * test-serialize-cell ] all?
+        40 [        test-serialize-cell ] all-integers?
+         4 [ 40 *   test-serialize-cell ] all-integers?
+         4 [ 400 *  test-serialize-cell ] all-integers?
+         4 [ 4000 * test-serialize-cell ] all-integers?
         and and and
-    ] all?
+    ] all-integers?
 ] unit-test
 
 TUPLE: serialize-test a b ;
index 9b4b0ac46b9651be7bd68fafe8668728d35c66bf..0840c778d7923473d6a3c434b8c7aed0cded8ad7 100644 (file)
@@ -240,7 +240,7 @@ SYMBOL: deserialized
     [ ] tri ;
 
 : copy-seq-to-tuple ( seq tuple -- )
-    [ dup length ] dip [ set-array-nth ] curry 2each ;
+    [ set-array-nth ] curry each-index ;
 
 : deserialize-tuple ( -- array )
     #! Ugly because we have to intern the tuple before reading
index 0ff41edec621ffc1b74d33f0603b722539cc0228..b826606df51f85070e4d9ddb17270b3a1e9625a4 100644 (file)
@@ -8,7 +8,7 @@ IN: shuffle
 <PRIVATE
 
 : >index-assoc ( sequence -- assoc )
-    dup length zip >hashtable ;
+    dup length iota zip >hashtable ;
 
 PRIVATE>
 
index 78b1493920cca026cde6aa54b8e9085f3e5cb462..b7fefcad635c9d04d381d34fa669a86069db073e 100644 (file)
@@ -13,4 +13,4 @@ PRIVATE>
 
 : insertion-sort ( seq quot -- )
     ! quot is a transformation on elements
-    over length [ insert ] with with each ; inline
+    over length [ insert ] with with each-integer ; inline
index 3641345a3ebd2bd9179e1224d9e8df1dbf69d146..32bb8b46c6edf5ff46297dc20c70ff820202e2d8 100644 (file)
@@ -26,7 +26,7 @@ PRIVATE>
 : (monotonic-slice) ( seq quot class -- slices )
     [
         dupd '[
-            [ length ] [ ] [ <circular> 1 over change-circular-start ] tri
+            [ length iota ] [ ] [ <circular> 1 over change-circular-start ] tri
             [ @ not [ , ] [ drop ] if ] 3each
         ] { } make
         dup empty? [ over length 1 - prefix ] when -1 prefix 2 clump
index d008c4921d6519d9c092fa0cce8c404b1558995f..e577f0fe69fa64e2fdaa98775a61dcbb9724f8d0 100644 (file)
@@ -1,6 +1,6 @@
-! Copyright (C) 2008, 2009 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel prettyprint io debugger
+USING: accessors arrays kernel prettyprint io debugger
 sequences assocs stack-checker.errors summary effects ;
 IN: stack-checker.errors.prettyprint
 
@@ -15,7 +15,7 @@ M: unbalanced-branches-error summary
 
 M: unbalanced-branches-error error.
     dup summary print
-    [ quots>> ] [ branches>> [ length <effect> ] { } assoc>map ] bi zip
+    [ quots>> ] [ branches>> [ length "x" <array> <effect> ] { } assoc>map ] bi zip
     [ [ first pprint-short bl ] [ second effect>string print ] bi ] each ;
 
 M: too-many->r summary
index 38ac2b0e719a24fb66f63e9c35f6dd928da46fab..20d61b9c3769cf829f64d519d88cb7a16fb8a931 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry namespaces assocs kernel sequences words accessors
 definitions math math.order effects classes arrays combinators
@@ -42,7 +42,7 @@ loop? ;
 : make-copies ( values effect-in -- values' )
     [ length cut* ] keep
     [ quotation-param? [ copy-value ] [ drop <value> ] if ] 2map
-    [ make-values ] dip append ;
+    [ length make-values ] dip append ;
 
 SYMBOL: enter-in
 SYMBOL: enter-out
index bbd8ecc40759212c50bbaf422af4fbc27500bbd0..b217f4d659628781381d6dc04c386cda6adc9223 100644 (file)
@@ -153,7 +153,7 @@ M: bad-executable summary
 
 : infer-<tuple-boa> ( -- )
     \ <tuple-boa>
-    peek-d literal value>> second 1 + { tuple } <effect>
+    peek-d literal value>> second 1 + "obj" <array> { tuple } <effect>
     apply-word/effect ;
 
 \ <tuple-boa> [ infer-<tuple-boa> ] "special" set-word-prop
index 6718d31d7aa819f522303ddcc5e88f69b5c706d2..8a0724556e8ad95a676ff964716b17b778740a70 100644 (file)
@@ -289,21 +289,21 @@ DEFER: an-inline-word
 
 ERROR: custom-error ;
 
-[ T{ effect f 0 0 t } ] [
+[ T{ effect f { } { } t } ] [
     [ custom-error ] infer
 ] unit-test
 
 : funny-throw ( a -- * ) throw ; inline
 
-[ T{ effect f 0 0 t } ] [
+[ T{ effect f { } { } t } ] [
     [ 3 funny-throw ] infer
 ] unit-test
 
-[ T{ effect f 0 0 t } ] [
+[ T{ effect f { } { } t } ] [
     [ custom-error inference-error ] infer
 ] unit-test
 
-[ T{ effect f 1 2 t } ] [
+[ T{ effect f { "x" } { "x" "x" } t } ] [
     [ dup [ 3 throw ] dip ] infer
 ] unit-test
 
index 1c527abfe49e63eb59f6ae889dd3911fb82049af..f0b595ebe5c2ebfa4f54be0a36f65fa7312ad223 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs arrays namespaces sequences kernel definitions
 math effects accessors words fry classes.algebra
@@ -38,7 +38,9 @@ SYMBOL: literals
 : current-stack-height ( -- n ) meta-d length input-count get - ;
 
 : current-effect ( -- effect )
-    input-count get meta-d length terminated? get effect boa ;
+    input-count get "x" <array>
+    meta-d length "x" <array>
+    terminated? get effect boa ;
 
 : init-inference ( -- )
     terminated? off
index 51032264c7ad4c50aafdf4f50e8b02afcd6334c1..19d0051d176a6008fd92b0f955bee142a236adb2 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences fry math.order splitting ;
 IN: strings.tables
@@ -6,7 +6,7 @@ IN: strings.tables
 <PRIVATE
 
 : map-last ( seq quot -- seq )
-    [ dup length <reversed> ] dip '[ 0 = @ ] 2map ; inline
+    [ dup length iota <reversed> ] dip '[ 0 = @ ] 2map ; inline
 
 : max-length ( seq -- n )
     [ length ] [ max ] map-reduce ;
index f486adcb32e27f882289eb4a6b4b567c41706126..134c144fda07442be067257492139cfb21299452 100644 (file)
@@ -7,7 +7,7 @@ IN: suffix-arrays
 <PRIVATE
 
 : suffixes ( string -- suffixes-seq )
-    dup length [ tail-slice ] with map ;
+    dup length iota [ tail-slice ] with map ;
 
 : prefix<=> ( begin seq -- <=> )
     [ <=> ] [ swap head? ] 2bi [ drop +eq+ ] when ;
index f9196e295186e23f49012eb73376d09929dcc905..4568b7c491c76cf73b077f5ffdd3108107ed076c 100644 (file)
@@ -1,6 +1,6 @@
 USING: namespaces io tools.test threads kernel
 concurrency.combinators concurrency.promises locals math
-words calendar ;
+words calendar sequences ;
 IN: threads.tests
 
 3 "x" set
@@ -20,7 +20,7 @@ yield
 [ f ] [ f get-global ] unit-test
 
 { { 0 3 6 9 12 15 18 21 24 27 } } [
-    10 [
+    10 iota [
         0 "i" tset
         [
             "i" [ yield 3 + ] tchange
index f75adcbf04d6944b670346f7813ef0a921b2e819..690103edf5eeb2a0ca8ee22e1c62d805188182ed 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: byte-arrays strings sequences sequences.private ascii
 fry kernel words parser lexer assocs math math.order summary ;
@@ -17,7 +17,7 @@ M: bad-tr summary
     [ [ ascii? ] all? ] both? [ bad-tr ] unless ;
 
 : compute-tr ( quot from to -- mapping )
-    [ 128 ] 3dip zip
+    [ 128 iota ] 3dip zip
     '[ [ _ call( x -- y ) _ at ] keep or ] B{ } map-as ; inline
 
 : tr-hints ( word -- )
index 92e7541616f3507d05075fa5a7ec5d04d38db358..ce69388ca2f5f1ebcf2ba163ee9531654ab1843f 100644 (file)
@@ -10,7 +10,7 @@ IN: tuple-arrays
 
 MACRO: boa-unsafe ( class -- quot ) tuple-layout '[ _ <tuple-boa> ] ;
 
-MACRO: infer-in ( class -- quot ) infer in>> '[ _ ] ;
+MACRO: infer-in ( class -- quot ) infer in>> length '[ _ ] ;
 
 : tuple-arity ( class -- quot ) '[ _ boa ] infer-in ; inline
 
@@ -28,7 +28,7 @@ MACRO: infer-in ( class -- quot ) infer in>> '[ _ ] ;
 
 MACRO: write-tuple ( class -- quot )
     [ '[ [ _ boa ] undo ] ]
-    [ tuple-arity <reversed> [ '[ [ _ ] dip set-nth-unsafe ] ] map '[ _ cleave ] ]
+    [ tuple-arity iota <reversed> [ '[ [ _ ] dip set-nth-unsafe ] ] map '[ _ cleave ] ]
     bi '[ _ dip @ ] ;
 
 PRIVATE>
index d7f77d9e549301c9bd19ce58b763ac47165eda80..ea16abb9bae6ba80697f68042a5e483800086216 100644 (file)
@@ -123,7 +123,7 @@ M: mock-gadget ungraft*
             <mock-gadget> over <model> >>model
             "g" get over add-gadget drop
             swap 1 + number>string set
-        ] each ;
+        ] each-integer ;
 
     : status-flags ( -- seq )
         { "g" "1" "2" "3" } [ get graft-state>> ] map prune ;
index b49f46c05a9e4429533f9a0c4cc8fdcd45f9f743..7ca83ce465c1ba3e6fd8ebb24d661a53f3e15ff7 100644 (file)
@@ -1,14 +1,14 @@
 USING: ui.gadgets.packs ui.gadgets.packs.private
 ui.gadgets.labels ui.gadgets ui.gadgets.debug ui.render
 ui.baseline-alignment kernel namespaces tools.test math.parser
-sequences math.rectangles accessors ;
+sequences math.rectangles accessors math ;
 IN: ui.gadgets.packs.tests
 
 [ t ] [
     { 0 0 } { 100 100 } <rect> clip set
 
     <pile>
-        100 [ number>string <label> add-gadget ] each
+        100 [ number>string <label> add-gadget ] each-integer
     dup layout
 
     visible-children [ label? ] all?
index 01abe8b3d958c0175ee1f81b2a7be511fc65a917..847e14df8a07aba9da31061cfa505085710951ae 100644 (file)
@@ -12,7 +12,7 @@ IN: ui.gadgets.panes.tests
 [ ] [ #children "num-children" set ] unit-test
 
 [ ] [
-    "pane" get <pane-stream> [ 100 [ . ] each ] with-output-stream*
+    "pane" get <pane-stream> [ 100 [ . ] each-integer ] with-output-stream*
 ] unit-test
 
 [ t ] [ #children "num-children" get = ] unit-test
index 5f5cc91846cd1a5649a550ff03b6bd81f0910d14..c89461cd5ab01d218238199692632e35a46c6072 100644 (file)
@@ -70,7 +70,7 @@ dup layout
 "s" set
 
 [ t ] [
-    10 [
+    10 iota [
         drop
         "g2" get scroll>gadget
         "s" get layout
index e49c60a3ed21458d264e0b24abc5c5be21b6bcb3..f1b856949c05024b16b91318d67161504a96d930 100644 (file)
@@ -1,4 +1,4 @@
 IN: ui.gadgets.slots.tests
 USING: assocs ui.gadgets.slots tools.test refs ;
 
-[ t ] [ [ ] [ ] { 1 2 3 } 2 <value-ref> <slot-editor> slot-editor? ] unit-test
+[ t ] [ [ ] [ ] { { 1 1 } { 2 2 } { 3 3 } } 2 <value-ref> <slot-editor> slot-editor? ] unit-test
index bbce857681bd17540a928ce624a8eff2ffae4fd5..0311b43474860111105d812f62fe4b5eec0c9f97 100644 (file)
@@ -27,7 +27,12 @@ IN: unicode.breaks.tests
     utf8 file-lines
     [ "#" split1 drop ] map harvest [
         "÷" split
-        [ "×" split [ [ blank? ] trim hex> ] map harvest >string ] map
+        [
+            "×" split
+            [ [ blank? ] trim hex> ] map
+            [ { f 0 } member? not ] filter
+            >string
+        ] map
         harvest
     ] map ;
 
@@ -46,4 +51,4 @@ IN: unicode.breaks.tests
 grapheme-break-test parse-test-file [ >graphemes ] test
 word-break-test parse-test-file [ >words ] test
 
-[ { t f t t f t } ] [ 6 [ "as df" word-break-at? ] map ] unit-test
+[ { t f t t f t } ] [ 6 iota [ "as df" word-break-at? ] map ] unit-test
index 7c7b8a1f50771499672eb752680021570141ccd4..46651bd7de8c1f2a345c7dc742e115d3f403ce95 100644 (file)
@@ -74,14 +74,14 @@ SYMBOL: table
   
 : make-grapheme-table ( -- )
     { CR } { LF } connect
-    { Control CR LF } graphemes disconnect
-    graphemes { Control CR LF } disconnect
+    { Control CR LF } graphemes iota disconnect
+    graphemes iota { Control CR LF } disconnect
     { L } { L V LV LVT } connect
     { LV V } { V T } connect
     { LVT T } { T } connect
-    graphemes { Extend } connect
-    graphemes { SpacingMark } connect
-    { Prepend } graphemes connect ;
+    graphemes iota { Extend } connect
+    graphemes iota { SpacingMark } connect
+    { Prepend } graphemes iota connect ;
 
 VALUE: grapheme-table
 
@@ -154,8 +154,8 @@ SYMBOL: check-number-after
 
 : make-word-table ( -- )
     { wCR } { wLF } connect
-    { wNewline wCR wLF } words disconnect
-    words { wNewline wCR wLF } disconnect
+    { wNewline wCR wLF } words iota disconnect
+    words iota { wNewline wCR wLF } disconnect
     { wALetter } { wMidLetter wMidNumLet } check-letter-after set-table
     { wMidLetter wMidNumLet } { wALetter } check-letter-before set-table
     { wNumeric wALetter } { wNumeric wALetter } connect
@@ -252,7 +252,7 @@ PRIVATE>
     over tail-slice first-word + ;
 
 : last-word ( str -- i )
-    [ length ] keep '[ _ word-break-at? ] find-last drop 0 or ;
+    [ length iota ] keep '[ _ word-break-at? ] find-last drop 0 or ;
 
 : last-word-from ( end str -- i )
     swap head-slice last-word ;
index ea0487c703525e8c9b311ebdf8f7e5484e3ca269..dc3cd89b51097f5b6cfcdd50a486b444e512d1b5 100644 (file)
@@ -82,7 +82,7 @@ ducet insert-helpers
 \r
 : add ( char -- )\r
     dup blocked? [ 1string , ] [\r
-        dup possible-bases dup length\r
+        dup possible-bases dup length iota\r
         [ ?combine ] with with any?\r
         [ drop ] [ 1string , ] if\r
     ] if ;\r
index 1c6c6afdf35711473774469afc0cc9e116e0a907..24dfba6be02dab57ec4a1f89bd091c22d67b7529 100644 (file)
@@ -108,7 +108,8 @@ PRIVATE>
 
 : exclusions ( -- set )
     exclusions-file utf8 file-lines
-    [ "#" split1 drop [ blank? ] trim-tail hex> ] map harvest ;
+    [ "#" split1 drop [ blank? ] trim-tail hex> ] map
+    [ 0 = not ] filter ;
 
 : remove-exclusions ( alist -- alist )
     exclusions [ dup ] H{ } map>assoc assoc-diff ;
index a672c850d29914a8cacab1b40dc4d371e0e7b243..5217cb48984f705d9a9d30c0578a07ff93ff79b1 100644 (file)
@@ -1,11 +1,12 @@
-! Copyright (C) 2005, 2008 Slava Pestov.
+! Copyright (C) 2005, 2010 Slava Pestov.
 ! Copyright (C) 2008 Eduardo Cavazos.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.syntax kernel libc
-sequences continuations byte-arrays strings math namespaces
-system combinators vocabs.loader accessors
-stack-checker macros locals generalizations unix.types
-io vocabs classes.struct unix.time alien.libraries ;
+USING: alien alien.c-types alien.syntax kernel libc sequences
+continuations byte-arrays strings math namespaces system
+combinators combinators.smart combinators.smart.private
+vocabs.loader accessors stack-checker macros locals
+generalizations unix.types io vocabs classes.struct unix.time
+alien.libraries ;
 IN: unix
 
 CONSTANT: PROT_NONE   0
@@ -48,7 +49,7 @@ ERROR: unix-error errno message ;
 ERROR: unix-system-call-error args errno message word ;
 
 MACRO:: unix-system-call ( quot -- )
-    quot infer in>> :> n
+    quot inputs :> n
     quot first :> word
     [
         n ndup quot call dup 0 < [
index 89eb1cdebd48a923595818bfee3d8194d601ea93..565f07037fec9fa2b3f641383f23aa217d274cf5 100644 (file)
@@ -1,5 +1,5 @@
 USING: unrolled-lists tools.test deques kernel sequences
-random prettyprint grouping ;
+random prettyprint grouping math ;
 IN: unrolled-lists.tests
 
 [ 1 ] [ <unrolled-list> 1 over push-front pop-front ] unit-test
@@ -35,23 +35,23 @@ IN: unrolled-lists.tests
 
 [ { 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 } ] [
     <unrolled-list>
-    32 [ over push-front ] each
+    32 [ over push-front ] each-integer
     32 [ dup pop-back ] replicate
     nip
 ] unit-test
 
 [ { 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 } ] [
     <unrolled-list>
-    32 [ over push-front ] each
+    32 [ over push-front ] each-integer
     32 [ dup pop-front ] replicate reverse
     nip
 ] unit-test
 
 [ t ] [
     <unrolled-list>
-    1000 [ 1000 random ] replicate
+    1000 [ 1000 iota random ] replicate
     [ [ over push-front ] each ]
-    [ [ dup pop-back ] replicate ]
+    [ length [ dup pop-back ] replicate ]
     [ ]
     tri
     =
@@ -60,11 +60,11 @@ IN: unrolled-lists.tests
 
 [ t ] [
     <unrolled-list>
-    1000 [ 1000 random ] replicate
+    1000 [ 1000 iota random ] replicate
     [
         10 group [
             [ [ over push-front ] each ]
-            [ [ dup pop-back ] replicate ]
+            [ length [ dup pop-back ] replicate ]
             bi 
         ] map concat
     ] keep
index 55b5147abba72a48b0bbddc5bb3e719e4a0e0de1..b25eca8d68cb6582d4601fdc8d289b8d3244296f 100644 (file)
@@ -1,6 +1,7 @@
-USING: accessors assocs combinators continuations fry generalizations
-io.pathnames kernel macros sequences stack-checker tools.test xml
-xml.traversal xml.writer arrays xml.data ; 
+USING: accessors assocs combinators combinators.smart
+continuations fry generalizations io.pathnames kernel macros
+sequences stack-checker tools.test xml xml.traversal xml.writer
+arrays xml.data ;
 IN: xml.tests.suite
 
 TUPLE: xml-test id uri sections description type ;
@@ -19,14 +20,11 @@ TUPLE: xml-test id uri sections description type ;
 
 CONSTANT: base "vocab:xml/tests/xmltest/"
 
-MACRO: drop-output ( quot -- newquot )
-    dup infer out>> '[ @ _ ndrop ] ;
-
-MACRO: drop-input ( quot -- newquot )
-    infer in>> '[ _ ndrop ] ;
+MACRO: drop-inputs ( quot -- newquot )
+    infer in>> length '[ _ ndrop ] ;
 
 : fails? ( quot -- ? )
-    [ drop-output f ] [ nip drop-input t ] bi-curry recover ; inline
+    [ drop-outputs f ] [ nip drop-inputs t ] bi-curry recover ; inline
 
 : well-formed? ( uri -- answer )
     [ file>xml ] fails? "not-wf" "valid" ? ;
index beb5983b5a61ce1f1158736e3bd0212b6de9f60d..ef8420d66c8012199bf001a55c9069ad63749e87 100644 (file)
@@ -95,7 +95,7 @@ HINTS: next* { spot } ;
     get-char [ missing-close ] unless next ;
 
 : expect ( string -- )
-    dup spot get '[ _ [ char>> ] keep next* ] replicate
+    dup length spot get '[ _ [ char>> ] keep next* ] "" replicate-as
     2dup = [ 2drop ] [ expected ] if ;
 
 ! Suddenly XML-specific
index e441855ed1929ba011a029a72004d257dcddcf9c..7b50d7c443232d3943f0c6c7be56d8f3d6bb0e45 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2007, 2009 Daniel Ehrenberg, Slava Pestov
+! Copyright (C) 2007, 2010 Daniel Ehrenberg, Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences arrays math sequences.private vectors
 accessors ;
@@ -225,7 +225,7 @@ M: enum set-at seq>> set-nth ; inline
 M: enum delete-at seq>> remove-nth! drop ; inline
 
 M: enum >alist ( enum -- alist )
-    seq>> [ length ] keep zip ; inline
+    seq>> [ length iota ] keep zip ; inline
 
 M: enum assoc-size seq>> length ; inline
 
index fdf4ab6aca99c6c4600a20d76ae80abbf36d5b14..286b7c419e101749edc59c51ca2b838c9157aa36 100644 (file)
@@ -1,11 +1,11 @@
 USING: tools.test byte-vectors vectors sequences kernel\r
-prettyprint ;\r
+prettyprint math ;\r
 IN: byte-vectors.tests\r
 \r
 [ 0 ] [ 123 <byte-vector> length ] unit-test\r
 \r
 : do-it ( seq -- seq )\r
-    123 [ over push ] each ;\r
+    123 [ over push ] each-integer ;\r
 \r
 [ t ] [\r
     3 <byte-vector> do-it\r
index c016b0169bf22808088a86abbd700c94c738fa78..11cb11d334c4f692e1d9789ee96f4d58969c54dc 100644 (file)
@@ -206,7 +206,6 @@ INSTANCE: union-with-one-member mixin-with-one-member
 \r
 ! class<=>\r
 \r
-[ +lt+ ] [ integer sequence class<=> ] unit-test\r
 [ +lt+ ] [ sequence object class<=> ] unit-test\r
 [ +gt+ ] [ object sequence class<=> ] unit-test\r
 [ +eq+ ] [ integer integer class<=> ] unit-test\r
@@ -266,7 +265,7 @@ INSTANCE: union-with-one-member mixin-with-one-member
 10 [\r
     [ ] [\r
         20 [ random-op ] [ ] replicate-as\r
-        [ infer in>> [ random-class ] times ] keep\r
+        [ infer in>> length [ random-class ] times ] keep\r
         call\r
         drop\r
     ] unit-test\r
@@ -300,7 +299,7 @@ INSTANCE: union-with-one-member mixin-with-one-member
 20 [\r
     [ t ] [\r
         20 [ random-boolean-op ] [ ] replicate-as dup .\r
-        [ infer in>> [ random-boolean ] replicate dup . ] keep\r
+        [ infer in>> length [ random-boolean ] replicate dup . ] keep\r
         \r
         [ [ [ ] each ] dip call ] 2keep\r
         \r
index a2617d0ebbfda4df8da27e91fde0b5f9e167a1f9..988be0dd88a6bf3c5257cec15fed13fbec127cd3 100644 (file)
@@ -22,7 +22,7 @@ IN: continuations.tests
         ] with-scope
     ] callcc0 "x" get 5 = ;
 
-[ t ] [ 10 callcc1-test 10 reverse >vector = ] unit-test
+[ t ] [ 10 callcc1-test 10 iota reverse >vector = ] unit-test
 [ t ] [ callcc-namespace-test ] unit-test
 
 [ 5 throw ] [ 5 = ] must-fail-with
index 38b8ab4dad2986985777795cdb52f4dc9891e200..134faea0270bc5f10adeb087e2d828f4d2e41d8c 100644 (file)
@@ -56,7 +56,7 @@ HELP: effect>string
 { $values { "obj" object } { "str" string } }
 { $description "Turns a stack effect object into a string mnemonic." }
 { $examples
-    { $example "USING: effects io ;" "1 2 <effect> effect>string print" "( object -- object object )" }
+    { $example "USING: effects io ;" "{ \"x\" } { \"y\" \"z\" } <effect> effect>string print" "( x -- y z )" }
 } ;
 
 HELP: stack-effect
index 8adef62795081e24116fde8d3a1c4bb96b3f1f44..ffc0c9780b27daeeb35dca386d6fa3112607bd32 100644 (file)
@@ -2,11 +2,11 @@ USING: effects kernel tools.test prettyprint accessors
 quotations sequences ;
 IN: effects.tests
 
-[ t ] [ 1 1 <effect> 2 2 <effect> effect<= ] unit-test
-[ f ] [ 1 0 <effect> 2 2 <effect> effect<= ] unit-test
-[ t ] [ 2 2 <effect> 2 2 <effect> effect<= ] unit-test
-[ f ] [ 3 3 <effect> 2 2 <effect> effect<= ] unit-test
-[ f ] [ 2 3 <effect> 2 2 <effect> effect<= ] unit-test
+[ t ] [ { "a" } { "a" } <effect> { "a" "b" } { "a" "b" } <effect> effect<= ] unit-test
+[ f ] [ { "a" } { } <effect> { "a" "b" } { "a" "b" } <effect> effect<= ] unit-test
+[ t ] [ { "a" "b" } { "a" "b" } <effect> { "a" "b" } { "a" "b" } <effect> effect<= ] unit-test
+[ f ] [ { "a" "b" "c" } { "a" "b" "c" } <effect> { "a" "b" } { "a" "b" } <effect> effect<= ] unit-test
+[ f ] [ { "a" "b" } { "a" "b" "c" } <effect> { "a" "b" } { "a" "b" } <effect> effect<= ] unit-test
 [ 2 ] [ (( a b -- c )) in>> length ] unit-test
 [ 1 ] [ (( a b -- c )) out>> length ] unit-test
 
index 8c1699f8d654def0d58ae5bae2f4d2eb124e222c..1790399e04d2c47a964f98c52a8c608a98be2c99 100644 (file)
@@ -1,34 +1,33 @@
-! Copyright (C) 2006, 2009 Slava Pestov.
+! Copyright (C) 2006, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math math.parser math.order namespaces make sequences strings
 words assocs combinators accessors arrays quotations ;
 IN: effects
 
-TUPLE: effect { in read-only } { out read-only } { terminated? read-only } ;
-
-GENERIC: effect-length ( obj -- n )
-M: sequence effect-length length ;
-M: integer effect-length ;
+TUPLE: effect
+{ in array read-only }
+{ out array read-only }
+{ terminated? read-only } ;
 
 : <effect> ( in out -- effect )
-    dup { "*" } sequence= [ drop { } t ] [ f ] if
+    dup { "*" } = [ drop { } t ] [ f ] if
     effect boa ;
 
 : effect-height ( effect -- n )
-    [ out>> effect-length ] [ in>> effect-length ] bi - ; inline
+    [ out>> length ] [ in>> length ] bi - ; inline
 
 : effect<= ( effect1 effect2 -- ? )
     {
         { [ over terminated?>> ] [ t ] }
         { [ dup terminated?>> ] [ f ] }
-        { [ 2dup [ in>> effect-length ] bi@ > ] [ f ] }
+        { [ 2dup [ in>> length ] bi@ > ] [ f ] }
         { [ 2dup [ effect-height ] bi@ = not ] [ f ] }
         [ t ]
     } cond 2nip ; inline
 
 : effect= ( effect1 effect2 -- ? )
-    [ [ in>> effect-length ] bi@ = ]
-    [ [ out>> effect-length ] bi@ = ]
+    [ [ in>> length ] bi@ = ]
+    [ [ out>> length ] bi@ = ]
     [ [ terminated?>> ] bi@ = ]
     2tri and and ;
 
@@ -40,7 +39,6 @@ M: integer effect>string number>string ;
 M: pair effect>string first2 [ effect>string ] bi@ ": " glue ;
 
 : stack-picture ( seq -- string )
-    dup integer? [ "object" <repetition> ] when
     [ [ effect>string % CHAR: \s , ] each ] "" make ;
 
 M: effect effect>string ( effect -- string )
@@ -56,10 +54,14 @@ M: effect effect>string ( effect -- string )
 GENERIC: effect>type ( obj -- type )
 M: object effect>type drop object ;
 M: word effect>type ;
-! attempting to specialize on callable breaks compiling
-! M: effect effect>type drop callable ;
 M: pair effect>type second effect>type ;
 
+: effect-in-types ( effect -- input-types )
+    in>> [ effect>type ] map ;
+
+: effect-out-types ( effect -- input-types )
+    out>> [ effect>type ] map ;
+
 GENERIC: stack-effect ( word -- effect/f )
 
 M: word stack-effect "declared-effect" word-prop ;
@@ -73,7 +75,7 @@ M: effect clone
     stack-effect effect-height ;
 
 : split-shuffle ( stack shuffle -- stack1 stack2 )
-    in>> effect-length cut* ;
+    in>> length cut* ;
 
 : shuffle-mapping ( effect -- mapping )
     [ out>> ] [ in>> ] bi [ index ] curry map ;
@@ -88,14 +90,9 @@ M: effect clone
     over terminated?>> [
         drop
     ] [
-        [ [ [ in>> effect-length ] [ out>> effect-length ] bi ] [ in>> effect-length ] bi* swap [-] + ]
-        [ [ out>> effect-length ] [ [ in>> effect-length ] [ out>> effect-length ] bi ] bi* [ [-] ] dip + ]
+        [ [ [ in>> length ] [ out>> length ] bi ] [ in>> length ] bi* swap [-] + ]
+        [ [ out>> length ] [ [ in>> length ] [ out>> length ] bi ] bi* [ [-] ] dip + ]
         [ nip terminated?>> ] 2tri
-        [ [ [ "obj" ] replicate ] bi@ ] dip
+        [ [ "x" <array> ] bi@ ] dip
         effect boa
     ] if ; inline
-
-: effect-in-types ( effect -- input-types )
-    in>> [ effect>type ] map ;
-: effect-out-types ( effect -- input-types )
-    out>> [ effect>type ] map ;
index 05cc27f5e8bfc0e48e61ba4336de65717e7cd81f..541f98ab9ca3ecbe00ac4c3996f84343568d0346 100644 (file)
@@ -3,14 +3,12 @@ sequences.private hashtables io prettyprint assocs
 continuations ;
 IN: hashtables.tests
 
-[ f ] [ "hi" V{ 1 2 3 } at ] unit-test
-
 [ H{ } ] [ { } [ dup ] H{ } map>assoc ] unit-test
 
-[ ] [ 1000 [ dup sq ] H{ } map>assoc "testhash" set ] unit-test
+[ ] [ 1000 iota [ dup sq ] H{ } map>assoc "testhash" set ] unit-test
 
 [ V{ } ]
-[ 1000 [ dup sq swap "testhash" get at = not ] filter ]
+[ 1000 iota [ dup sq swap "testhash" get at = not ] filter ]
 unit-test
 
 [ t ]
@@ -118,7 +116,7 @@ H{ } clone "counting" set
 
 ! Resource leak...
 H{ } "x" set
-100 [ drop "x" get clear-assoc ] each
+100 [ drop "x" get clear-assoc ] each-integer
 
 ! Crash discovered by erg
 [ t ] [ 0.75 <hashtable> dup clone = ] unit-test
@@ -173,4 +171,4 @@ H{ } "x" set
 [ 1 ] [ 2 "h" get at ] unit-test
 
 ! Random test case
-[ "A" ] [ 100 [ dup ] H{ } map>assoc 32 over delete-at "A" 32 pick set-at 32 swap at ] unit-test
+[ "A" ] [ 100 iota [ dup ] H{ } map>assoc 32 over delete-at "A" 32 pick set-at 32 swap at ] unit-test
index 088131acf9e0a0ba6c90a0ed2d99efc7b5509cc1..efebe7bd25431717da6a562a36012d87f3639bc0 100644 (file)
@@ -28,4 +28,4 @@ IN: io.encodings.utf8.tests
 
 [ 3 ] [ 2 "lápis" >utf8-index ] unit-test
 
-[ V{ } ] [ 100000 [ [ code-point-length ] [ 1string utf8 encode length ] bi = not ] filter ] unit-test
+[ V{ } ] [ 100000 iota [ [ code-point-length ] [ 1string utf8 encode length ] bi = not ] filter ] unit-test
index 2c0884c8b127c3c121f8a6b109970f492a03a435..84f993c5ac9a95dae1c149c22a7353909356dcdb 100644 (file)
@@ -58,7 +58,7 @@ unit-test
 
 [ 0 ] [ 1/0. >bignum ] unit-test
 
-[ t ] [ 64 [ 2^ 0.5 * ] map [ < ] monotonic? ] unit-test
+[ t ] [ 64 iota [ 2^ 0.5 * ] map [ < ] monotonic? ] unit-test
 
 [ 5 ] [ 10.5 1.9 /i ] unit-test
 
index 3f9384e02df4e20a6f8abefd9411d13171a2b310..768607ade8abd3665a8bec0c32f4106a026adaea 100644 (file)
@@ -216,8 +216,8 @@ unit-test
 
 : random-integer ( -- n )
     32 random-bits
-    1 random zero? [ neg ] when
-    1 random zero? [ >bignum ] when ;
+    1 iota random zero? [ neg ] when
+    1 iota random zero? [ >bignum ] when ;
 
 [ t ] [
     1000 [
@@ -225,7 +225,7 @@ unit-test
         random-integer
         random-integer
         [ >float / ] [ /f ] 2bi 0.1 ~
-    ] all?
+    ] all-integers?
 ] unit-test
 
 ! Ensure that /f is accurate for fixnums > 2^53 on 64-bit platforms
index ac3f565e5678784473968c1b752eedb3780a5cec..6711870f74c585a956f6aa65f65463d1688177e6 100644 (file)
@@ -21,4 +21,4 @@ IN: sbufs.tests
 
 [ fixnum ] [ 1 >bignum SBUF" " new-sequence length class ] unit-test
 
-[ fixnum ] [ 1 >bignum [ ] SBUF" " map-as length class ] unit-test
+[ fixnum ] [ 1 >bignum iota [ ] SBUF" " map-as length class ] unit-test
index aeab243a2f60adf3cb7c0145aa7e6e09a2e44381..59852464259f3a58fe9bc8f6432ccdb41ae4c650 100644 (file)
@@ -1140,9 +1140,9 @@ HELP: set-fourth
 
 HELP: replicate
 { $values
-     { "seq" sequence } { "quot" { $quotation "( -- elt )" } }
+     { "len" integer } { "quot" { $quotation "( -- elt )" } }
      { "newseq" sequence } }
-{ $description "Calls the quotation for every element of the sequence in order. However, the element is not passed to the quotation -- it is dropped, and the quotation produces an element of its own that is collected into a sequence of the same class as the input sequence." }
+     { $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new array." }
 { $examples 
     { $unchecked-example "USING: kernel prettyprint random sequences ;"
         "5 [ 100 random ] replicate ."
@@ -1152,15 +1152,16 @@ HELP: replicate
 
 HELP: replicate-as
 { $values
-     { "seq" sequence } { "quot" quotation } { "exemplar" sequence }
+     { "len" integer } { "quot" quotation } { "exemplar" sequence }
      { "newseq" sequence } }
-{ $description "Calls the quotation for every element of the sequence in order. However, the element is not passed to the quotation -- it is dropped, and the quotation produces an element of its own that is collected into a sequence of the same class as the exemplar sequence." }
+ { $description "Calls the quotation " { $snippet "len" } " times, collecting results into a new sequence of the same type as the exemplar sequence." }
 { $examples 
     { $unchecked-example "USING: prettyprint kernel sequences ;"
         "5 [ 100 random ] B{ } replicate-as ."
         "B{ 44 8 2 33 18 }"
     }
 } ;
+
 { replicate replicate-as } related-words
 
 HELP: partition
index c82caec3f9769772d61069f7a01fba6b122e7f23..10be0454b98f7c235cc45f01f9f16fb4f63577fc 100644 (file)
@@ -6,13 +6,13 @@ IN: sequences.tests
 [ "empty" ] [ { } [ "empty" ] [ "not empty" ] if-empty ] unit-test
 [ { 1 } "not empty" ] [ { 1 } [ "empty" ] [ "not empty" ] if-empty ] unit-test
 
-[ V{ 1 2 3 4 } ] [ 1 5 dup <slice> >vector ] unit-test
-[ 3 ] [ 1 4 dup <slice> length ] unit-test
+[ V{ 1 2 3 4 } ] [ 1 5 dup iota <slice> >vector ] unit-test
+[ 3 ] [ 1 4 dup iota <slice> length ] unit-test
 [ 2 ] [ 1 3 { 1 2 3 4 } <slice> length ] unit-test
 [ V{ 2 3 } ] [ 1 3 { 1 2 3 4 } <slice> >vector ] unit-test
 [ V{ 4 5 } ] [ { 1 2 3 4 5 } 2 tail-slice* >vector ] unit-test
-[ V{ 3 4 } ] [ 2 4 1 10 dup <slice> subseq >vector ] unit-test
-[ V{ 3 4 } ] [ 0 2 2 4 1 10 dup <slice> <slice> subseq >vector ] unit-test
+[ V{ 3 4 } ] [ 2 4 1 10 dup iota <slice> subseq >vector ] unit-test
+[ V{ 3 4 } ] [ 0 2 2 4 1 10 dup iota <slice> <slice> subseq >vector ] unit-test
 [ 0 10 "hello" <slice> ] must-fail
 [ -10 3 "hello" <slice> ] must-fail
 [ 2 1 "hello" <slice> ] must-fail
@@ -129,7 +129,7 @@ unit-test
 [ { 1 3 2 4 } ] [ { 1 2 3 4 } clone 1 2 pick exchange ] unit-test
 
 [ { "" "a" "aa" "aaa" } ]
-[ 4 [ CHAR: a <string> ] map ]
+[ 4 [ CHAR: a <string> ] { } map-integers ]
 unit-test
 
 [ V{ } ] [ "f" V{ } clone remove! ] unit-test
@@ -138,11 +138,11 @@ unit-test
 [ V{ "x" } ] [ "f" V{ "f" "x" "f" } clone remove! ] unit-test
 [ V{ "y" "x" } ] [ "f" V{ "y" "f" "x" "f" } clone remove! ] unit-test
 
-[ V{ 0 1 4 5 } ] [ 6 >vector 2 4 pick delete-slice ] unit-test
+[ V{ 0 1 4 5 } ] [ 6 iota >vector 2 4 pick delete-slice ] unit-test
 
 [ 6 >vector 2 8 pick delete-slice ] must-fail
 
-[ V{ } ] [ 6 >vector 0 6 pick delete-slice ] unit-test
+[ V{ } ] [ 6 iota >vector 0 6 pick delete-slice ] unit-test
 
 [ { 1 2 "a" "b" 5 6 7 } ] [
     { "a" "b" } 2 4 { 1 2 3 4 5 6 7 }
@@ -228,10 +228,10 @@ unit-test
 
 [ 0 ] [ f length ] unit-test
 [ f first ] must-fail
-[ 3 ] [ 3 10 nth ] unit-test
-[ 3 ] [ 3 10 nth-unsafe ] unit-test
-[ -3 10 nth ] must-fail
-[ 11 10 nth ] must-fail
+[ 3 ] [ 3 10 iota nth ] unit-test
+[ 3 ] [ 3 10 iota nth-unsafe ] unit-test
+[ -3 10 iota nth ] must-fail
+[ 11 10 iota nth ] must-fail
 
 [ -1/0. 0 remove-nth! ] must-fail
 [ "" ] [ "" [ CHAR: \s = ] trim ] unit-test
@@ -243,10 +243,10 @@ unit-test
 [ "asdf " ] [ " asdf " [ CHAR: \s = ] trim-head ] unit-test
 [ " asdf" ] [ " asdf " [ CHAR: \s = ] trim-tail ] unit-test
 
-[ 328350 ] [ 100 [ sq ] map-sum ] unit-test
+[ 328350 ] [ 100 iota [ sq ] map-sum ] unit-test
 
-[ 50 ] [ 100 [ even? ] count ] unit-test
-[ 50 ] [ 100 [ odd?  ] count ] unit-test
+[ 50 ] [ 100 iota [ even? ] count ] unit-test
+[ 50 ] [ 100 iota [ odd?  ] count ] unit-test
 
 [ { "b" "d" } ] [ { 1 3 } { "a" "b" "c" "d" } nths ] unit-test
 [ { "a" "b" "c" "d" } ] [ { 0 1 2 3 } { "a" "b" "c" "d" } nths ] unit-test
index 16949f5542da48d43daba98dfbaff786e7a655c2..7d1e45aca0ffb0db67182d67e0593b4c23dfd138 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2009 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2005, 2010 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel kernel.private slots.private math
 math.private math.order ;
@@ -98,12 +98,6 @@ M: f like drop [ f ] when-empty ; inline
 
 INSTANCE: f immutable-sequence
 
-! Integers used to support the sequence protocol
-M: integer length ; inline
-M: integer nth-unsafe drop ; inline
-
-INSTANCE: integer immutable-sequence
-
 PRIVATE>
 
 ! In the future, this will replace integer sequences
@@ -426,11 +420,11 @@ PRIVATE>
 : map ( seq quot -- newseq )
     over map-as ; inline
 
-: replicate ( seq quot -- newseq )
-    [ drop ] prepose map ; inline
+: replicate-as ( len quot exemplar -- newseq )
+    [ [ drop ] prepose ] dip map-integers ; inline
 
-: replicate-as ( seq quot exemplar -- newseq )
-    [ [ drop ] prepose ] dip map-as ; inline
+: replicate ( len quot -- newseq )
+    { } replicate-as ; inline
 
 : map! ( seq quot -- seq )
     over [ map-into ] keep ; inline
@@ -466,7 +460,7 @@ PRIVATE>
     (2each) all-integers? ; inline
 
 : 3each ( seq1 seq2 seq3 quot -- )
-    (3each) each ; inline
+    (3each) each-integer ; inline
 
 : 3map-as ( seq1 seq2 seq3 quot exemplar -- newseq )
     [ (3each) ] dip map-integers ; inline
index 0bda4ba9b0be9e4324c69677d6734c4a7c1e3d3e..447dd1fb2b8f7c4cae6634299c211ba2244939dc 100644 (file)
@@ -5,16 +5,16 @@ IN: sorting.tests
 [ { } ] [ { } natural-sort ] unit-test
 
 [ { 270000000 270000001 } ]
-[ T{ slice f 270000000 270000002 270000002 } natural-sort ]
+[ T{ slice f 270000000 270000002 T{ iota f 270000002 } } natural-sort ]
 unit-test
 
 [ t ] [
     100 [
         drop
-        100 [ 20 random [ 1000 random ] replicate ] replicate
+        100 [ 20 iota random [ 1000 iota random ] replicate ] replicate
         dup natural-sort
         [ set= ] [ nip [ before=? ] monotonic? ] 2bi and
-    ] all?
+    ] all-integers?
 ] unit-test
 
 [ ] [ { 1 2 } [ 2drop 1 ] sort drop ] unit-test
index 4f5473ce9de921869ee2e94e7245102c19d90943..b3b6daee5957174fdb8a559caa25333f6576e6e9 100644 (file)
@@ -20,7 +20,7 @@ M: source-file-error error-line [ error>> error-line ] [ line#>> ] bi or ;
 M: source-file-error compute-restarts error>> compute-restarts ;
 
 : sort-errors ( errors -- alist )
-    [ [ line#>> ] sort-with ] { } assoc-map-as sort-keys ;
+    [ [ line#>> 0 or ] sort-with ] { } assoc-map-as sort-keys ;
 
 : group-by-source-file ( errors -- assoc )
     H{ } clone [ [ push-at ] curry [ dup file>> ] prepose each ] keep ;
index 689d88be7156cc2c1b60ad09df47e4cf5456f3ce..b90d96a356e0809616fa2d87c698139d8c747307 100644 (file)
@@ -116,5 +116,5 @@ unit-test
         drop
         300 100 CHAR: \u123456
         [ <string> clone resize-string first ] keep =
-    ] all?
+    ] all-integers?
 ] unit-test
index 9052638e7da914b9e41c0b1e4a8d2d5b45c4388a..79248584e9a99a66807829f03e7ed8457a4f7fb9 100644 (file)
@@ -26,7 +26,7 @@ IN: vectors.tests
 [ V{ 1 2 } ] [ [ 1 2 ] >vector ] unit-test
 
 [ t ] [
-    100 [ 100 random ] V{ } replicate-as
+    100 [ 100 iota random ] V{ } replicate-as
     dup >array >vector =
 ] unit-test
 
@@ -91,11 +91,11 @@ IN: vectors.tests
 [ 4 ] [ 5 V{ 1 2 3 4 5 } index ] unit-test
 
 [ t ] [
-    100 >array dup >vector <reversed> >array [ reverse ] dip =
+    100 iota >array dup >vector <reversed> >array [ reverse ] dip =
 ] unit-test
 
 [ fixnum ] [ 1 >bignum V{ } new-sequence length class ] unit-test
 
-[ fixnum ] [ 1 >bignum [ ] V{ } map-as length class ] unit-test
+[ fixnum ] [ 1 >bignum iota [ ] V{ } map-as length class ] unit-test
 
 [ V{ "lulz" } ] [ "lulz" 1vector ] unit-test
index f49d21d5a36829664733903f94b73b54af176758..51cafbe1e8596b1f602e43df9e6da15c350e3b9b 100644 (file)
@@ -2,7 +2,7 @@ IN: benchmark.iteration
 USING: sequences vectors arrays strings sbufs math math.vectors
 kernel ;
 
-: <range> ( from to -- seq ) dup <slice> ; inline
+: <range> ( from to -- seq ) dup iota <slice> ; inline
 
 : vector-iter ( -- ) 100 [ 0 100000 <range> >vector [ ] map drop ] times ;
 : array-iter ( -- ) 100 [ 0 100000 <range> >array [ ] map drop ] times ;
index fa56aff8cc92898c8cf3c64c57054cc906c33f70..14c6b4145338cde2f3288818caf17eec54a85f7f 100644 (file)
@@ -70,11 +70,11 @@ IN: bloom-filters.tests
 ] unit-test
 
 ! We shouldn't have more than 0.01 false-positive rate.
-[ t ] [ 1000 iota [ drop most-positive-fixnum random 1000 + ] map
+[ t ] [ 1000 iota [ drop most-positive-fixnum iota random 1000 + ] map
         full-bloom-filter
         [ bloom-filter-member? ] curry map
-        [ ] filter
+        [ ] count
         ! TODO: This should be 10, but the false positive rate is currently very
         ! high.  300 is large enough not to prevent builds from succeeding.
-        length 300 <=
+        300 <=
 ] unit-test
index a5a6709c6d61c2d555ecbf68560cc3a1ca208fd4..4891eab6902f25fd115c0c02ecb20457a4ef222e 100644 (file)
@@ -44,7 +44,7 @@ CONSTANT: AES_BLOCK_SIZE 16
 
 : inv-sbox ( -- array )
     256 0 <array>
-    dup 256 [ dup sbox nth rot set-nth ] with each ;
+    dup 256 [ dup sbox nth rot set-nth ] with each-integer ;
 
 : rcon ( -- array )
     {
@@ -72,7 +72,7 @@ CONSTANT: AES_BLOCK_SIZE 16
 
 MEMO:: t-table ( -- array )
     1024 0 <array>
-    dup 256 [ set-t ] with each ;
+    dup 256 [ set-t ] with each-integer ;
 
 :: set-d ( D i -- )
     i inv-sbox nth :> a1
@@ -91,7 +91,7 @@ MEMO:: t-table ( -- array )
     
 MEMO:: d-table ( -- array )
     1024 0 <array>
-    dup 256 [ set-d ] with each ;
+    dup 256 [ set-d ] with each-integer ;
 
 
 USE: multiline
index 29b9d98b38548e4fa8489ceeb13ddb40558d2a07..34ad094bc8e074b67c56154d1696fa8502b7b218 100644 (file)
@@ -10,7 +10,7 @@ IN: decimals.tests
 ] unit-test
 
 : random-test-int ( -- n )
-    10 random 2 random 0 = [ neg ] when ;
+    10 iota random 2 iota random 0 = [ neg ] when ;
 
 : random-test-decimal ( -- decimal )
     random-test-int random-test-int <decimal> ;
@@ -26,15 +26,15 @@ ERROR: decimal-test-failure D1 D2 quot ;
 : test-decimal-op ( quot1 quot2 -- ? )
     [ random-test-decimal random-test-decimal ] 2dip (test-decimal-op) ; inline
 
-[ t ] [ 1000 [ drop [ D+ ] [ + ] test-decimal-op ] all? ] unit-test
-[ t ] [ 1000 [ drop [ D- ] [ - ] test-decimal-op ] all? ] unit-test
-[ t ] [ 1000 [ drop [ D* ] [ * ] test-decimal-op ] all? ] unit-test
+[ t ] [ 1000 [ drop [ D+ ] [ + ] test-decimal-op ] all-integers? ] unit-test
+[ t ] [ 1000 [ drop [ D- ] [ - ] test-decimal-op ] all-integers? ] unit-test
+[ t ] [ 1000 [ drop [ D* ] [ * ] test-decimal-op ] all-integers? ] unit-test
 [ t ] [
     1000 [
         drop
         [ [ 100 D/ ] [ /f ] test-decimal-op ]
         [ { "kernel-error" 4 f f } = ] recover
-    ] all?
+    ] all-integers?
 ] unit-test
 
 [ t ] [ 
index 10fcd9c449ade7c150ae2cb4469fa209cc13b645..2d0b9514ffee2dab36a0c2569a32df11cb9e6dbd 100644 (file)
@@ -61,10 +61,10 @@ TUPLE: link attributes clickable ;
     ] map ;
 
 : find-by-id ( vector id -- vector' elt/f )
-    '[ attributes>> "id" at _ = ] find ;
+    '[ attributes>> "id" swap at _ = ] find ;
     
 : find-by-class ( vector id -- vector' elt/f )
-    '[ attributes>> "class" at _ = ] find ;
+    '[ attributes>> "class" swap at _ = ] find ;
 
 : find-by-name ( vector string -- vector elt/f )
     >lower '[ name>> _ = ] find ;
index 9bb755807771054a1aaf8cda2a74ec6abd8f058d..bc3a387fd0cc4aa4b5e0bee8593de40527c5788a 100644 (file)
@@ -43,4 +43,4 @@ IN: id3.tests
 
 
 [ t ]
-[ 10000 [ synchsafe>seq seq>synchsafe ] map [ < ] monotonic? ] unit-test
+[ 10000 iota [ synchsafe>seq seq>synchsafe ] map [ < ] monotonic? ] unit-test
index f94fc979ce630961f78d8272d383763473d777f2..5dc88936beb5efc9b5590b071bb35b32b6d2a44e 100644 (file)
@@ -21,7 +21,7 @@ C: <segment> segment
     0 swap length clamp ;
 
 : random-color ( -- color )
-    { 100 100 100 } [ random 100 / >float ] map first3 1.0 <rgba> ;
+    { 100 100 100 } [ iota random 100 / >float ] map first3 1.0 <rgba> ;
 
 CONSTANT: tunnel-segment-distance 0.4
 CONSTANT: random-rotation-angle $[ pi 20 / ]
index f5b30f49da7a61dfa2659cec521e483d30195ed8..c35ba6ac8c0193922ba85c8b53879987713a6b64 100644 (file)
@@ -71,10 +71,10 @@ SYMBOL: terms
     [ natural-sort ] keep [ index ] curry map ;
 
 : (inversions) ( n seq -- n )
-    [ > ] with filter length ;
+    [ > ] with count ;
 
 : inversions ( seq -- n )
-    0 swap [ length ] keep [
+    0 swap [ length iota ] keep [
         [ nth ] 2keep swap 1 + tail-slice (inversions) +
     ] curry each ;
 
@@ -145,12 +145,12 @@ DEFER: (d)
     [ dup length pick nth push ] reduce ;
 
 : nth-basis-elt ( generators n -- elt )
-    over length [
+    over length iota [
         3dup bit? [ nth ] [ 2drop f ] if
     ] map sift 2nip ;
 
 : basis ( generators -- seq )
-    natural-sort dup length 2^ [ nth-basis-elt ] with map ;
+    natural-sort dup length 2^ iota [ nth-basis-elt ] with map ;
 
 : (tensor) ( seq1 seq2 -- seq )
     [
@@ -180,7 +180,7 @@ DEFER: (d)
     dim-im/ker-d ;
 
 : graded-ker/im-d ( graded-basis -- seq )
-    [ length ] keep [ (graded-ker/im-d) ] curry map ;
+    [ length iota ] keep [ (graded-ker/im-d) ] curry map ;
 
 : graded-betti ( generators -- seq )
     basis graded graded-ker/im-d unzip but-last 0 prefix v- ;
@@ -269,8 +269,8 @@ DEFER: (d)
     3array ;
 
 :: bigraded-triples ( grid -- triples )
-    grid length [| z |
-        grid first length [| u |
+    grid length iota [| z |
+        grid first length iota [| u |
             u z grid bigraded-triple
         ] map
     ] map ;
index 6d01744290ab9f889308788a092e11f22c6de9b3..e4052836b4ffca8662be7df633c198233b6f3746 100644 (file)
@@ -18,7 +18,7 @@ CONSTANT: gamma-p6
     }
 
 : gamma-z ( x n -- seq )
-    [ + recip ] with map 1.0 0 pick set-nth ;
+    [ + recip ] with { } map-integers 1.0 0 pick set-nth ;
 
 : (gamma-lanczos6) ( x -- log[gamma[x+1]] )
     #! log(gamma(x+1)
index 422036d5cc39ae6c44c819f5632c926439653c17..5b2af13489fd7286b01e658fb5edbf59729904fb 100644 (file)
@@ -83,7 +83,7 @@ SYMBOL: and-needed?
         first 3digits>text
     ] [
         [ set-conjunction "" ] [ length ] [ ] tri
-        [ (recombine) ] curry each
+        [ (recombine) ] curry each-integer
     ] if ;
 
 : (number>text) ( n -- str )
index 33d1fbedcbc58fb36f51b36caed11f844f306fad..a053c058537d23333999916659b15aaada4d69a6 100644 (file)
@@ -1,6 +1,6 @@
 ! (c)2009 Joe Groff bsd license
 USING: accessors arrays bit-arrays classes
-classes.tuple.private fry kernel locals parser
+classes.tuple.private fry kernel locals math parser
 sequences sequences.private vectors words ;
 IN: memory.pools
 
@@ -10,7 +10,7 @@ TUPLE: pool
 
 : <pool> ( size class -- pool )
     [ nip new ]
-    [ [ iota ] dip '[ _ new ] V{ } replicate-as ] 2bi
+    [ '[ _ new ] V{ } replicate-as ] 2bi
     pool boa ;
 
 : pool-size ( pool -- size )
@@ -20,7 +20,7 @@ TUPLE: pool
 
 :: copy-tuple ( from to -- to )
     from tuple-size :> size
-    size [| n | n from array-nth n to set-array-nth ] each
+    size [| n | n from array-nth n to set-array-nth ] each-integer
     to ; inline
 
 : (pool-new) ( pool -- object )
index de131df3c6a84b4a3217dd7f3a37934c88318063..6bed6d5f32ee18f7dae771236ce64cd31b342770 100644 (file)
@@ -21,7 +21,7 @@ SYMBOL: total
 : canonicalize-specializer-1 ( specializer -- specializer' )
     [
         [ class? ] filter
-        [ length <reversed> [ 1 + neg ] map ] keep zip
+        [ length iota <reversed> [ 1 + neg ] map ] keep zip
         [ length args [ max ] change ] keep
     ]
     [
@@ -111,7 +111,7 @@ SYMBOL: total
     swap "predicate" word-prop append ;
 
 : multi-predicate ( classes -- quot )
-    dup length <reversed>
+    dup length iota <reversed>
     [ picker 2array ] 2map
     [ drop object eq? not ] assoc-filter
     [ [ t ] ] [
index e3d8cb7fd91036be60d2c339b8c006b60142ae54..fb7f00f62912d0a69591202e782ba2fbc5e98f47 100644 (file)
@@ -6,7 +6,7 @@ SYMBOL: sum
 
 : range ( r from to -- n )
     over - 1 + rot [ 
-        '[ over + @ drop ] each drop f
+        '[ over + @ drop ] each-integer drop f
     ] bshift 2nip ; inline
 
 [ 55 ] [
index beed787fba1504fb86708b992623b3e386fa72bb..241fc2b626355c7ff0f14387367225a3dd7164c3 100644 (file)
@@ -72,12 +72,12 @@ IN: project-euler.011
 
 : pad-front ( matrix -- matrix )
     [
-        length [ 0 <repetition> ] map
+        length iota [ 0 <repetition> ] map
     ] keep [ append ] 2map ;
 
 : pad-back ( matrix -- matrix )
     <reversed> [
-        length [ 0 <repetition> ] map
+        length iota [ 0 <repetition> ] map
     ] keep [ <reversed> append ] 2map ;
 
 : diagonal/ ( -- matrix )
index 49680177d525fb57bb69218141e32e270b1ab91c..cbf45c9e326281ab44a10276424cb421d97aa6cf 100644 (file)
@@ -47,7 +47,7 @@ PRIVATE>
     [ [ dup 1 > ] [ dup , next-collatz ] while , ] { } make ;
 
 : euler014 ( -- answer )
-    1000000 [1,b] 0 [ collatz longest ] reduce first ;
+    1000000 [1,b] { } [ collatz longest ] reduce first ;
 
 ! [ euler014 ] time
 ! 52868 ms run / 483 ms GC time
@@ -64,7 +64,7 @@ PRIVATE>
 PRIVATE>
 
 : euler014a ( -- answer )
-    500000 1000000 [a,b] 1 [
+    500000 1000000 [a,b] { 1 } [
         dup worth-calculating? [ collatz longest ] [ drop ] if
     ] reduce first ;
 
index f6b4d497c070ae45150178a0166e5b42e1c09717..71e44ccb1e925dc09570a8274a19d21a46da8eb7 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (c) 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math.combinatorics math.parser project-euler.common ;
+USING: kernel math.combinatorics math.parser project-euler.common
+sequences ;
 IN: project-euler.024
 
 ! http://projecteuler.net/index.php?section=problems&id=24
@@ -23,7 +24,7 @@ IN: project-euler.024
 ! --------
 
 : euler024 ( -- answer )
-    999999 10 permutation 10 digits>integer ;
+    999999 10 iota permutation 10 digits>integer ;
 
 ! [ euler024 ] 100 ave-time
 ! 0 ms ave run time - 0.27 SD (100 trials)
index 814f8a5a6382d92187e616db9901315fc33d8a6e..8fb7a2bfaa8c83b45d0d8d7203cb1fb6ac3b1a46 100644 (file)
@@ -28,7 +28,7 @@ IN: project-euler.032
 
 : source-032 ( -- seq )
     9 factorial iota [
-        9 permutation [ 1 + ] map 10 digits>integer
+        9 iota permutation [ 1 + ] map 10 digits>integer
     ] map ;
 
 : 1and4 ( n -- ? )
index cf4955750636a769bdb4ba2e88086991ae5109e9..4991d65a895c4f7c032ed0f68c134d774c35d23b 100644 (file)
@@ -40,13 +40,13 @@ IN: project-euler.043
 
 : interesting? ( seq -- ? )
     {
-        [ 17 8 rot subseq-divisible? ]
-        [ 13 7 rot subseq-divisible? ]
-        [ 11 6 rot subseq-divisible? ]
-        [ 7  5 rot subseq-divisible? ]
-        [ 5  4 rot subseq-divisible? ]
-        [ 3  3 rot subseq-divisible? ]
-        [ 2  2 rot subseq-divisible? ]
+        [ [ 17 8 ] dip subseq-divisible? ]
+        [ [ 13 7 ] dip subseq-divisible? ]
+        [ [ 11 6 ] dip subseq-divisible? ]
+        [ [ 7  5 ] dip subseq-divisible? ]
+        [ [ 5  4 ] dip subseq-divisible? ]
+        [ [ 3  3 ] dip subseq-divisible? ]
+        [ [ 2  2 ] dip subseq-divisible? ]
     } 1&& ;
 
 PRIVATE>
@@ -82,7 +82,7 @@ PRIVATE>
     [ unclip 1 head prefix concat ] map [ all-unique? ] filter ;
 
 : add-missing-digit ( seq -- seq )
-    dup natural-sort 10 swap diff prepend ;
+    dup natural-sort 10 iota swap diff prepend ;
 
 : interesting-pandigitals ( -- seq )
     17 candidates { 13 11 7 5 3 2 } [
index 037cc87288420e13ab0823aaaef63ba22287663d..ae603c81fd498bf4f1e96c2139bc231b476e4cfd 100644 (file)
@@ -24,7 +24,7 @@ IN: project-euler.052
 <PRIVATE
 
 : map-nx ( n x -- seq )
-    [ 1 + * ] with map ; inline
+    iota [ 1 + * ] with map ; inline
 
 : all-same-digits? ( seq -- ? )
     [ number>digits natural-sort ] map all-equal? ;
index faca6a8ad56ce5c372767e0683282937ffb4f226..2e2d31740192e3df3f9181cd66a1f5b79732de2e 100644 (file)
@@ -27,7 +27,7 @@ IN: project-euler.053
 ! --------
 
 : euler053 ( -- answer )
-    23 100 [a,b] [ dup [ nCk 1000000 > ] with count ] map-sum ;
+    23 100 [a,b] [ dup iota [ nCk 1000000 > ] with count ] map-sum ;
 
 ! [ euler053 ] 100 ave-time
 ! 52 ms ave run time - 4.44 SD (100 trials)
index e6278a1e172297e77e4b7105274340352138ddb9..6e64d6ad3080a491121c003aca5ba5bc5f28f32e 100644 (file)
@@ -55,9 +55,9 @@ IN: project-euler.150
 
 :: (euler150) ( m -- n )
     sums-triangle :> table
-    m [| x |
-        x 1 + [| y |
-            m x - [0,b) [| z |
+    m iota [| x |
+        x 1 + iota [| y |
+            m x - iota [| z |
                 x z + table nth-unsafe
                 [ y z + 1 + swap nth-unsafe ]
                 [ y        swap nth-unsafe ] bi -
index ccdb76d80e05ca679f5b464c27b6adf5bb9fd396..b8db55e886e00421e9f7a1443b99540faff6f4e5 100644 (file)
@@ -62,7 +62,7 @@ DEFER: (euler151)
         { { 0 0 1 0 } [ { 0 0 0 1 } (euler151) 1 + ] }
         { { 0 1 0 0 } [ { 0 0 1 1 } (euler151) 1 + ] }
         { { 1 0 0 0 } [ { 0 1 1 1 } (euler151) 1 + ] }
-        [ [ dup length [ pick-sheet ] with map sum ] [ sum ] bi / ]
+        [ [ dup length iota [ pick-sheet ] with map sum ] [ sum ] bi / ]
      } case ] cache ;
 
 : euler151 ( -- answer )
index af8b7e49c064d3de79794f7602ce04f4edf0dbc7..be5d40df9b92aefd9405ab47c8fa0e6a1f5003bd 100644 (file)
@@ -18,7 +18,7 @@ IN: project-euler.164
 <PRIVATE
 
 : next-keys ( key -- keys )
-    [ last ] [ 10 swap sum - ] bi [ 2array ] with map ;
+    [ last ] [ 10 swap sum - iota ] bi [ 2array ] with map ;
 
 : next-table ( assoc -- assoc )
     H{ } clone swap
index 9eb9e968ca161c60b1f679206b873d88bf2772a4..a84f4fa48b3aff39506e2713581a89bc6fa142e4 100644 (file)
@@ -39,7 +39,7 @@ IN: project-euler.common
 <PRIVATE
 
 : max-children ( seq -- seq )
-    [ dup length 1 - [ nth-pair max , ] with each ] { } make ;
+    [ dup length 1 - iota [ nth-pair max , ] with each ] { } make ;
 
 ! Propagate one row into the upper one
 : propagate ( bottom top -- newtop )
index 19b0dead484fc094396d936dae56544eac9b4747..fe552a77a1d6e9d9cc095d64b0e55e70c84e146b 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2007, 2009 Slava Pestov.
+! Copyright (C) 2007, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays hashtables help.markup help.stylesheet io
 io.styles kernel math models namespaces sequences ui ui.gadgets
@@ -94,7 +94,7 @@ TUPLE: slides < book ;
     [ first3 ] dip head 3array ;
 
 : strip-tease ( data -- seq )
-    dup third length 1 - [
+    dup third length 1 - iota [
         2 + (strip-tease)
     ] with map ;
 
index 81b38f2c1450946e8794fb2f017a21b0d519575e..afbeea61108daac1f2af7943404ffef7e0593afa 100644 (file)
@@ -10,7 +10,7 @@ IN: smalltalk.compiler.tests
     ] with-compilation-unit ;
 
 : test-inference ( ast -- in# out# )
-    test-compilation infer [ in>> ] [ out>> ] bi ;
+    test-compilation infer [ in>> ] [ out>> ] bi [ length ] bi@ ;
 
 [ 2 1 ] [
     T{ ast-block f
index 2ea1e99afd1ce349fa6e1871f449c756d7a63192..609498634574e2eb834adca3f4f186f524d7e50c 100644 (file)
@@ -1,6 +1,6 @@
-! Copyright (C) 2009 Slava Pestov.
+! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators effects generic generic.standard
+USING: arrays combinators effects generic generic.standard
 kernel sequences words lexer ;
 IN: smalltalk.selectors
 
@@ -15,9 +15,9 @@ SYMBOLS: unary binary keyword ;
 
 : selector>effect ( selector -- effect )
     dup selector-type {
-        { unary [ drop 0 ] }
-        { binary [ drop 1 ] }
-        { keyword [ [ CHAR: : = ] count ] }
+        { unary [ drop { } ] }
+        { binary [ drop { "x" } ] }
+        { keyword [ [ CHAR: : = ] count "x" <array> ] }
     } case "receiver" suffix { "result" } <effect> ;
 
 : selector>generic ( selector -- generic )
index 1f12dcabe6454a5dd02ecc0651c2d255b40f05a4..2346999bcbc822ae69686dad6b97e191470d8842 100644 (file)
@@ -6,7 +6,7 @@ IN: tetris.board
 TUPLE: board { width integer } { height integer } rows ;
 
 : make-rows ( width height -- rows )
-    [ drop f <array> ] with map ;
+    iota [ drop f <array> ] with map ;
 
 : <board> ( width height -- board )
     2dup make-rows board boa ;
@@ -24,8 +24,8 @@ TUPLE: board { width integer } { height integer } rows ;
 : block-free? ( board block -- ? ) block not ;
 
 : block-in-bounds? ( board block -- ? )
-    [ first swap width>> bounds-check? ] 2keep
-    second swap height>> bounds-check? and ;
+    [ first swap width>> iota bounds-check? ]
+    [ second swap height>> iota bounds-check? ] 2bi and ;
 
 : location-valid? ( board block -- ? )
     2dup block-in-bounds? [ block-free? ] [ 2drop f ] if ;
index c07357fbdf7a5ba91a25fad87c6de7a962478fdb..d880d51390ed8592c589b37ea20a106526985a6b 100644 (file)
@@ -5,10 +5,10 @@ sequences random sets make grouping ;
 IN: trees.splay.tests
 
 : randomize-numeric-splay-tree ( splay-tree -- )
-    100 [ drop 100 random swap at drop ] with each ;
+    100 iota [ drop 100 iota random swap at drop ] with each ;
 
 : make-numeric-splay-tree ( n -- splay-tree )
-    <splay> [ [ conjoin ] curry each ] keep ;
+    iota <splay> [ [ conjoin ] curry each ] keep ;
 
 [ t ] [
     100 make-numeric-splay-tree dup randomize-numeric-splay-tree