A bit of a cleanup
parent
58dd889379
commit
32a95a79e4
|
@ -1,7 +1,7 @@
|
||||||
! Based on Clojure's PersistentVector by Rich Hickey.
|
! Based on Clojure's PersistentVector by Rich Hickey.
|
||||||
|
|
||||||
USING: math accessors kernel sequences.private sequences arrays
|
USING: math accessors kernel sequences.private sequences arrays
|
||||||
combinators parser prettyprint.backend fry debugger ;
|
combinators parser prettyprint.backend ;
|
||||||
IN: persistent-vectors
|
IN: persistent-vectors
|
||||||
|
|
||||||
ERROR: empty-error pvec ;
|
ERROR: empty-error pvec ;
|
||||||
|
@ -64,7 +64,6 @@ M: persistent-vector nth-unsafe
|
||||||
swap 1array >>children ;
|
swap 1array >>children ;
|
||||||
|
|
||||||
: 2node ( first second -- node )
|
: 2node ( first second -- node )
|
||||||
2dup [ level>> ] bi@ assert=
|
|
||||||
[ 2array ] [ drop level>> 1+ ] 2bi node boa ;
|
[ 2array ] [ drop level>> 1+ ] 2bi node boa ;
|
||||||
|
|
||||||
: new-child ( new-child node -- node' expansion/f )
|
: new-child ( new-child node -- node' expansion/f )
|
||||||
|
@ -102,9 +101,9 @@ M: persistent-vector ppush ( obj pvec -- pvec' )
|
||||||
clone [ new-nth ] change-children ;
|
clone [ new-nth ] change-children ;
|
||||||
|
|
||||||
: node-change-nth ( i node quot -- node' )
|
: node-change-nth ( i node quot -- node' )
|
||||||
[ clone ] dip '[
|
[ clone ] dip [
|
||||||
clone [ , change-nth ] keep
|
[ clone ] dip [ change-nth ] 2keep drop
|
||||||
] change-children ; inline
|
] curry change-children ; inline
|
||||||
|
|
||||||
: (new-nth) ( val i node -- node' )
|
: (new-nth) ( val i node -- node' )
|
||||||
dup level>> 0 = [
|
dup level>> 0 = [
|
||||||
|
|
Loading…
Reference in New Issue