Paste: experiment
Author: | slava |
Mode: | factor |
Date: | Fri, 14 Nov 2008 11:18:38 |
Plain Text |
FUNCTOR: define-vector ( T -- )
A IS ${T}-array
<A> IS <A>
V DEFINES ${T}-vector
<V> DEFINES <${V}>
>V DEFINES >${V}
V{ DEFINES ${V}{
IN
`TUPLE: V { underlying A } { length array-capacity } ;
`: <V> <A> execute 0 V boa ; `inline
`M: V like
drop dup V instance? [
dup A instance? [ dup length V boa ] [ >V ] if
] unless ;
`M: V new-sequence drop [ <V> ] [ >fixnum ] bi V boa ;
`M: A new-resizable drop <V> ;
;FUNCTOR
New Annotation