- faster layout\r
- faster repaint\r
- ui browser\r
-- auto-updating inspector, mirrors abstraction\r
- mouse enter onto overlapping with interior, but not child, gadget\r
- rollovers broken in inspector\r
- menu dragging\r
\r
+ sequences\r
\r
-- generic skip\r
- dipping 2nmap, 2each\r
- array sort\r
-- 2map slow with lists\r
- nappend: instead of using push, enlarge the sequence with set-length\r
then add set the elements with set-nth\r
- faster sequence operations\r
-- generic some? all? memq? fiber?\r
-- index and index* are very slow with lists\r
- specialized arrays\r
-- list map, subset: not tail recursive\r
- phase out sbuf-append\r
\r
+ kernel:\r
: compile? "compile" get supported-cpu? and ;
+"library/inference/branches.factor" run-file
+
compile? [
\ car compile
\ * compile
#! list.
2dup member? [ nip ] [ cons ] ifte ;
-M: general-list reverse ( list -- list )
+M: general-list reversed ( list -- list )
[ ] [ swons ] reduce ;
-M: f map ( list quot -- list ) drop ;
-
-M: cons map ( list quot -- list | quot: elt -- elt )
- (each) rot >r map r> swons ;
+M: general-list reverse reversed ;
IN: sequences
DEFER: <range>
#! Destructive on seq.
0 swap (nmap) ; inline
-M: object map ( seq quot -- seq | quot: elt -- elt )
- swap [ swap nmap ] immutable ;
+: map ( seq quot -- seq | quot: elt -- elt )
+ swap [ swap nmap ] immutable ; inline
+
+: map-with ( obj list quot -- list | quot: obj elt -- elt )
+ swap [ with rot ] map 2nip ; inline
+
+: accumulate ( list identity quot -- values | quot: x y -- z )
+ rot [ pick >r swap call r> ] map-with nip ; inline
: (2nmap) ( seq1 seq2 i quot -- elt3 )
pick pick >r >r >r 2nth r> call r> r> swap set-nth ; inline
: >pop> ( stack -- stack ) dup pop drop ;
+M: object reversed ( seq -- seq ) <reversed> ;
+
M: object reverse ( seq -- seq ) [ <reversed> ] keep like ;
! Set theoretic operations
-: seq-intersect ( seq seq -- seq )
- #! Make a list of elements that occur in both lists.
+: seq-intersect ( seq1 seq2 -- seq1/\seq2 )
[ swap member? ] subset-with ;
-: seq-diff ( list1 list2 -- list )
- #! Make a list of elements that occur in list2 but not
- #! list1.
+: seq-diff ( seq1 seq2 -- seq2-seq1 )
[ swap member? not ] subset-with ;
-: seq-diffq ( list1 list2 -- list )
- #! Make a list of elements that occur in list2 but not
- #! list1.
+: seq-diffq ( seq1 seq2 -- seq2-seq1 )
[ swap memq? not ] subset-with ;
-: contained? ( list1 list2 -- ? )
- #! Is every element of list1 in list2?
+: seq-union ( seq1 seq2 -- seq1\/seq2 )
+ append prune ;
+
+: contained? ( seq1 seq2 -- ? )
+ #! Is every element of seq1 in seq2
swap [ swap member? ] all-with? ;
IN: kernel
GENERIC: thaw ( seq -- mutable-seq )
GENERIC: like ( seq seq -- seq )
GENERIC: reverse ( seq -- seq )
+GENERIC: reversed ( seq -- seq )
GENERIC: peek ( seq -- elt )
GENERIC: head ( n seq -- seq )
GENERIC: tail ( n seq -- seq )
GENERIC: concat ( seq -- seq )
GENERIC: resize ( n seq -- seq )
+: immutable ( seq quot -- seq | quot: seq -- )
+ swap [ thaw ] keep >r dup >r swap call r> r> like ; inline
+
G: each ( seq quot -- | quot: elt -- )
[ over ] [ type ] ; inline
: reduce ( list identity quot -- value | quot: x y -- z )
swapd each ; inline
-G: map ( seq quot -- seq | quot: elt -- elt )
- [ over ] [ type ] ; inline
-
-: map-with ( obj list quot -- list | quot: obj elt -- elt )
- swap [ with rot ] map 2nip ; inline
-
-: accumulate ( list identity quot -- values | quot: x y -- z )
- rot [ pick >r swap call r> ] map-with nip ; inline
-
G: 2map ( seq seq quot -- seq | quot: elt elt -- elt )
[ over ] [ type ] ; inline
: find-with* ( obj i seq quot -- i elt )
-rot [ with rot ] find* 2swap 2drop ; inline
-: immutable ( seq quot -- seq | quot: seq -- )
- swap [ thaw ] keep >r dup >r swap call r> r> like ; inline
-
: first 0 swap nth ; inline
: second 1 swap nth ; inline
: third 2 swap nth ; inline
SYMBOL: object
-: type-union ( list list -- list )
- append prune ;
-
: lookup-union ( typelist -- class )
[ > ] sort typemap get hash [ object ] unless* ;
#! Return a class that both classes are subclasses of.
swap builtin-supertypes
swap builtin-supertypes
- type-union lookup-union ;
+ seq-union lookup-union ;
: class-or-list ( list -- class )
#! Return a class that every class in the list is a
[ length ] map 0 [ max ] reduce ;
: computed-value-vector ( n -- vector )
- empty-vector [ object <computed> ] map ;
+ empty-vector [ drop object <computed> ] map ;
: add-inputs ( count stack -- stack )
#! Add this many inputs to the given stack.
USING: alien generic io kernel lists math matrices namespaces
prettyprint sdl sequences vectors ;
-DEFER: pick-up
-
: (pick-up) ( point gadget -- gadget )
- gadget-children <reversed> [ pick-up ] find nip ;
+ gadget-children reversed [ inside? ] find-with nip ;
: pick-up ( point gadget -- gadget )
#! The logic is thus. If the point is definately outside the
#! in any subgadget. If not, see if it is contained in the
#! box delegate.
2dup inside? [
- [ [ translate ] keep (pick-up) dup ] keep ?
+ [ translate ] keep 2dup
+ (pick-up) [ pick-up ] [ nip ] ?ifte
] [
2drop f
] ifte ;
! See http://factor.sf.net/license.txt for BSD license.
IN: gadgets
USING: generic hashtables kernel lists math matrices namespaces
-sequences ;
+sequences vectors ;
: remove-gadget ( gadget parent -- )
[ 2dup gadget-children remq swap set-gadget-children ] keep
0 over gadget-children set-length relayout ;
: ?push ( elt seq/f -- seq )
- [ push ] [ 1vector ] ifte* ;
+ [ [ push ] keep ] [ 1vector ] ifte* ;
: (add-gadget) ( gadget box -- )
over unparent
TUPLE: pack align fill vector ;
: pref-dims ( gadget -- list )
- gadget-children [ pref-dim ] map ;
+ gadget-children [ pref-dim ] map >list ;
: orient ( gadget list1 list2 -- list )
zip >r pack-vector r> [ uncons rot set-axis ] map-with ;