+ misc:\r
\r
- directory listings:\r
+ - nicer way to combine two paths\r
- icons for file responder\r
- cwd, cd, pwd, dir., pwd. words\r
- -1.1 3 ^ shouldn't give a complex number\r
- don't rehash strings on every startup\r
- 'cascading' styles\r
- jedit ==> jedit-word, jedit takes a file name\r
-- rethink strhead/strtail&co\r
+- introduce ifte* and ?str-head/?str-tail where appropriate\r
- namespace clone drops static var bindings\r
- ditch expand\r
- set-object-path\r
USE: lists
USE: stack
-: 2apply ( x y [ code ] -- )
+: 2apply ( x y quot -- )
#! First applies the code to x, then to y.
#!
#! If the quotation compiles, this combinator compiles.
2dup >r >r nip call r> r> call ; inline interpret-only
-: cleave ( x [ code1 ] [ code2 ] -- )
+: cleave ( x quot quot -- )
#! Executes each quotation, with x on top of the stack.
#!
#! If the quotation compiles, this combinator compiles.
#! If the quotation compiles, this combinator compiles.
-rot >r >r call r> r> ; inline interpret-only
-: forever ( code -- )
+: forever ( quot -- )
#! The code is evaluated in an infinite loop. Typically, a
#! continuation is used to escape the infinite loop.
#!
pick [ drop call ] [ nip nip call ] ifte ;
inline interpret-only
-: interleave ( X list -- )
+: interleave ( X quot -- )
#! Evaluate each element of the list with X on top of the
#! stack. When done, X is popped off the stack.
#!
2drop
] ifte ; interpret-only
-: unless ( cond [ if false ] -- )
+: unless ( cond quot -- )
#! Execute a quotation only when the condition is f. The
#! condition is popped off the stack.
#!
#! values as it produces.
[ ] swap ifte ; inline interpret-only
-: unless* ( cond [ if false ] -- )
+: unless* ( cond quot -- )
#! If cond is f, pop it off the stack and evaluate the
#! quotation. Otherwise, leave cond on the stack.
#!
#! value than it produces.
over [ drop ] [ nip call ] ifte ; inline interpret-only
-: when ( cond [ if true ] -- )
+: when ( cond quot -- )
#! Execute a quotation only when the condition is not f. The
#! condition is popped off the stack.
#!
#! values as it produces.
[ ] ifte ; inline interpret-only
-: when* ( cond [ code ] -- )
+: when* ( cond quot -- )
#! If the condition is true, it is left on the stack, and
#! the quotation is evaluated. Otherwise, the condition is
#! popped off the stack.
#! value than it produces.
dupd [ drop ] ifte ; inline interpret-only
-: while ( [ P ] [ R ] -- )
- #! Evaluate P. If it leaves t on the stack, evaluate R, and
- #! recurse.
+: while ( cond body -- )
+ #! Evaluate cond. If it leaves t on the stack, evaluate
+ #! body, and recurse.
#!
- #! In order to compile, the stack effect of P * ( X -- ) * R
- #! must consume as many values as it produces.
+ #! In order to compile, the stack effect of
+ #! cond * ( X -- ) * body must consume as many values as
+ #! it produces.
2dup >r >r >r call [
r> call r> r> while
] [
#! Push a list of keys in a hashtable.
[ ] swap [ car swons ] hash-each ;
-: hash-values ( hash -- list )
+: hash-values ( hash -- alist )
#! Push a list of values in a hashtable.
[ ] swap [ cdr swons ] hash-each ;
: hash>alist ( hash -- list )
#! Push a list of key/value pairs in a hashtable.
[ ] swap [ swons ] hash-each ;
+
+: alist>hash ( alist -- hash )
+ 37 <hashtable> swap [ unswons pick set-hash ] each ;
USE: kernel
USE: stack
-: times ( n [ code ] -- )
+: times ( n quot -- )
#! Evaluate a quotation n times.
#!
#! In order to compile, the code must produce as many values
#! as it consumes.
- [
- over 0 >
+ tuck >r dup 0 <= [
+ r> 3drop
] [
- tuck >r pred >r call r> r>
- ] while 2drop ; inline interpret-only
+ pred >r call r> r> times
+ ] ifte ; inline interpret-only
-: times* ( n [ code ] -- )
+: (times) ( limit n quot -- )
+ pick pick <= [
+ 3drop
+ ] [
+ tuck >r tuck >r rot >r call r> r> succ r> (times)
+ ] ifte ; inline interpret-only
+
+: times* ( n quot -- )
#! Evaluate a quotation n times, pushing the index at each
#! iteration. The index ranges from 0 to n-1.
#!
#! In order to compile, the code must consume one more value
#! than it produces.
- 0 rot
- [
- 2dup <
- ] [
- >r 2dup succ >r >r swap call r> r> r>
- ] while
- 3drop ; inline interpret-only
+ 0 swap (times) ; inline interpret-only