From f8f5feed4aff44a87ca7dce1daefbcf851de8d7d Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 19 Feb 2013 16:52:40 -0800 Subject: [PATCH] sequences: normalize all the "?set-nth" words, probably this should be a stdlib thing. --- basis/bit-sets/bit-sets.factor | 11 ++++++++--- basis/game/input/iokit/iokit.factor | 4 ++-- basis/unicode/data/data.factor | 4 ++-- extra/maze/maze.factor | 8 ++++++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/basis/bit-sets/bit-sets.factor b/basis/bit-sets/bit-sets.factor index 495180c094..e7bde4b506 100644 --- a/basis/bit-sets/bit-sets.factor +++ b/basis/bit-sets/bit-sets.factor @@ -19,13 +19,18 @@ M: bit-set adjoin ! go in the set [ t ] 2dip table>> set-nth ; + + M: bit-set delete ! This isn't allowed to throw an error if the elt wasn't ! in the set over integer? [ - table>> 2dup bounds-check? [ - [ f ] 2dip set-nth - ] [ 2drop ] if + [ f ] 2dip table>> ?set-nth ] [ 2drop ] if ; ! If you do binary set operations with a bit-set, it's expected diff --git a/basis/game/input/iokit/iokit.factor b/basis/game/input/iokit/iokit.factor index 49121964e1..1112bacc95 100644 --- a/basis/game/input/iokit/iokit.factor +++ b/basis/game/input/iokit/iokit.factor @@ -177,8 +177,8 @@ CONSTANT: pov-values HINTS: record-controller { controller-state alien } ; -: ?set-nth ( value nth seq -- ) - 2dup bounds-check? [ set-nth-unsafe ] [ 3drop ] if ; +: ?set-nth ( elt n seq -- ) + 2dup bounds-check? [ set-nth-unsafe ] [ 3drop ] if ; inline : record-keyboard ( keyboard-state value -- ) dup IOHIDValueGetElement dup keyboard-key? [ diff --git a/basis/unicode/data/data.factor b/basis/unicode/data/data.factor index 03fc3b98ad..8bf275925f 100644 --- a/basis/unicode/data/data.factor +++ b/basis/unicode/data/data.factor @@ -138,8 +138,8 @@ PRIVATE> ! the maximum unicode char in the first 3 planes -: ?set-nth ( val index seq -- ) - 2dup bounds-check? [ set-nth ] [ 3drop ] if ; +: ?set-nth ( elt n seq -- ) + 2dup bounds-check? [ set-nth-unsafe ] [ 3drop ] if ; inline :: fill-ranges ( table -- table ) name-map sort-values keys diff --git a/extra/maze/maze.factor b/extra/maze/maze.factor index ecf3c49c89..4d964af132 100644 --- a/extra/maze/maze.factor +++ b/extra/maze/maze.factor @@ -10,8 +10,12 @@ SYMBOL: visited : unvisited? ( cell -- ? ) first2 visited get ?nth ?nth ; -: ?set-nth ( elt i seq -- ) - 2dup bounds-check? [ set-nth ] [ 3drop ] if ; + : visit ( cell -- ) f swap first2 visited get ?nth ?set-nth ;