]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences: define a single "?set-nth" that is used.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 20 Feb 2013 18:42:21 +0000 (10:42 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 20 Feb 2013 18:42:21 +0000 (10:42 -0800)
basis/bit-sets/bit-sets.factor
basis/game/input/iokit/iokit.factor
basis/unicode/data/data.factor
core/sequences/sequences-docs.factor
core/sequences/sequences.factor
extra/maze/maze.factor

index 30e0561ad04bd2ae67f0392abf00d8dfbcf83c45..320f0d3fa781df21660b423819f28e6ec5192ae4 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors sequences byte-arrays bit-arrays math
-math.bitwise hints sets sequences.private ;
+math.bitwise hints sets ;
 IN: bit-sets
 
 TUPLE: bit-set { table bit-array read-only } ;
@@ -19,13 +19,6 @@ M: bit-set adjoin
     ! go in the set
     [ t ] 2dip table>> set-nth ;
 
-<PRIVATE
-
-: ?set-nth ( elt n seq -- )
-    2dup bounds-check? [ set-nth-unsafe ] [ 3drop ] if ; inline
-
-PRIVATE>
-
 M: bit-set delete
     ! This isn't allowed to throw an error if the elt wasn't
     ! in the set
index 1112bacc95144fee65e89ae25e033966278df241..d07b0691603da122c6ec62be9197b960d91c197f 100644 (file)
@@ -1,11 +1,9 @@
-USING: cocoa cocoa.plists core-foundation iokit iokit.hid
-kernel cocoa.enumeration destructors math.parser cocoa.application 
-core-foundation.data core-foundation.strings
-sequences locals combinators.short-circuit threads
-namespaces assocs arrays combinators hints alien
-core-foundation.run-loop accessors sequences.private
-alien.c-types alien.data math parser game.input vectors
-bit-arrays unix.types ;
+USING: accessors alien alien.c-types arrays assocs bit-arrays
+cocoa.application cocoa.enumeration cocoa.plists combinators
+combinators.short-circuit core-foundation core-foundation.data
+core-foundation.run-loop core-foundation.strings destructors
+game.input hints iokit iokit.hid kernel locals math namespaces
+sequences vectors ;
 FROM: namespaces => change-global ;
 IN: game.input.iokit
 
@@ -177,9 +175,6 @@ CONSTANT: pov-values
 
 HINTS: record-controller { controller-state alien } ;
 
-: ?set-nth ( elt n seq -- )
-    2dup bounds-check? [ set-nth-unsafe ] [ 3drop ] if ; inline
-
 : record-keyboard ( keyboard-state value -- )
     dup IOHIDValueGetElement dup keyboard-key? [
         [ IOHIDValueGetIntegerValue c-bool> ]
index e32740391b7d813b73f3015974f3cbc2c1e36baf..860d5bb56fa40fbf614265e361cc08147ed8089e 100644 (file)
@@ -5,8 +5,7 @@ io.files hashtables quotations splitting grouping arrays io
 math.parser math.order byte-arrays namespaces math.bitwise
 compiler.units parser io.encodings.ascii interval-maps
 ascii sets combinators locals math.ranges sorting make
-strings.parser io.encodings.utf8 memoize simple-flat-file
-sequences.private ;
+strings.parser io.encodings.utf8 memoize simple-flat-file ;
 IN: unicode.data
 
 <PRIVATE
@@ -139,9 +138,6 @@ PRIVATE>
 
 ! the maximum unicode char in the first 3 planes
 
-: ?set-nth ( elt n seq -- )
-    2dup bounds-check? [ set-nth-unsafe ] [ 3drop ] if ; inline
-
 :: fill-ranges ( table -- table )
     name-map sort-values keys
     [ { [ "first>" tail? ] [ "last>" tail? ] } 1|| ] filter
index 18c96831928726b4cb532728bc0fc816c3afee26..b80a9dbca9fc27f2e92abe4331ff3e01460fd364 100644 (file)
@@ -179,6 +179,10 @@ HELP: ?nth
 { $values { "n" "an integer" } { "seq" sequence } { "elt/f" "an object or " { $link f } } }
 { $description "A forgiving version of " { $link nth } ". If the index is out of bounds, or if the sequence is " { $link f } ", simply outputs " { $link f } "." } ;
 
+HELP: ?set-nth
+{ $values { "elt" object } { "n" "an integer" } { "seq" sequence } }
+{ $description "A forgiving version of " { $link set-nth } ".  If the index is out of bounds, does nothing." } ;
+
 HELP: ?first
 { $values { "seq" sequence } { "elt/f" "an object or " { $link f } } }
 { $description "A forgiving version of " { $link first } ". If the sequence is empty, or if the sequence is " { $link f } ", simply outputs " { $link f } "." }
index a7db7b63b2f72c96394480908c4015d344ac70a2..3e6be3488254d7c2af197430b908afc1fa06f4cb 100644 (file)
@@ -175,6 +175,9 @@ PRIVATE>
 : ?nth ( n seq -- elt/f )
     2dup bounds-check? [ nth-unsafe ] [ 2drop f ] if ; inline
 
+: ?set-nth ( elt n seq -- )
+    2dup bounds-check? [ set-nth-unsafe ] [ 3drop ] if ; inline
+
 : ?first ( seq -- elt/f ) 0 swap ?nth ; inline
 : ?second ( seq -- elt/f ) 1 swap ?nth ; inline
 : ?last ( seq -- elt/f )
index bf98895b52e4cee84969894ade1699b81c10736e..0e4af964d3555e65c5d908846daa299fa444adc1 100644 (file)
@@ -1,7 +1,7 @@
 ! From http://www.ffconsultancy.com/ocaml/maze/index.html
 USING: accessors arrays fry kernel math math.order math.vectors
 namespaces opengl.gl random sequences ui ui.gadgets
-ui.gadgets.canvas ui.render sequences.private ;
+ui.gadgets.canvas ui.render ;
 IN: maze
 
 CONSTANT: line-width 8
@@ -10,13 +10,6 @@ SYMBOL: visited
 
 : unvisited? ( cell -- ? ) first2 visited get ?nth ?nth ;
 
-<PRIVATE
-
-: ?set-nth ( elt n seq -- )
-    2dup bounds-check? [ set-nth-unsafe ] [ 3drop ] if ; inline
-
-PRIVATE>
-
 : visit ( cell -- ) f swap first2 visited get ?nth ?set-nth ;
 
 : choices ( cell -- seq )