sequences: normalize all the "?set-nth" words, probably this should be a stdlib thing.

db4
John Benediktsson 2013-02-19 16:52:40 -08:00
parent b62444680b
commit f8f5feed4a
4 changed files with 18 additions and 9 deletions

View File

@ -19,13 +19,18 @@ 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
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

View File

@ -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? [

View File

@ -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

View File

@ -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 ;
<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 ;