factor/library/collections/tree-each.factor

26 lines
691 B
Factor
Raw Normal View History

2006-01-06 02:04:42 -05:00
! Copyright (C) 2005, 2006 Slava Pestov.
2005-07-16 22:16:18 -04:00
! See http://factor.sf.net/license.txt for BSD license.
IN: sequences
USING: generic kernel lists strings ;
2005-07-16 22:16:18 -04:00
2006-01-06 02:04:42 -05:00
G: tree-each* ( obj quot -- | quot: elt -- )
2005-08-22 15:33:18 -04:00
[ over ] standard-combination ; inline
2005-07-16 22:16:18 -04:00
2006-01-06 02:04:42 -05:00
: tree-each ( obj quot -- | quot: elt -- )
[ call ] 2keep tree-each* ; inline
2006-01-06 02:04:42 -05:00
2005-07-16 22:16:18 -04:00
: tree-each-with ( obj vector quot -- )
swap [ with ] tree-each 2drop ; inline
2006-01-06 02:04:42 -05:00
M: object tree-each* 2drop ;
2005-07-16 22:16:18 -04:00
2006-01-06 02:04:42 -05:00
M: sequence tree-each* swap [ swap tree-each ] each-with ;
2005-07-16 22:16:18 -04:00
2006-01-06 02:04:42 -05:00
M: string tree-each* 2drop ;
2006-01-06 02:04:42 -05:00
M: cons tree-each* ( cons quot -- )
2005-07-16 22:16:18 -04:00
>r uncons r> tuck >r >r tree-each r> r> tree-each ;
2006-01-06 02:04:42 -05:00
M: wrapper tree-each* ( wrapper quot -- )
>r wrapped r> tree-each ;