more removals of unnecessary >list calls

cvs
Slava Pestov 2005-07-23 03:21:50 +00:00
parent 315f9d547f
commit f2f1c6705b
8 changed files with 21 additions and 24 deletions

View File

@ -1,5 +1,3 @@
- timeouts broken on unix
+ ui:
- fix listener prompt display after presentation commands invoked

View File

@ -164,13 +164,13 @@ M: object >list ( seq -- list ) dup length 0 rot (>list) ;
#! Return a new sequence of the same type as s1.
rot [ [ rot nappend ] keep swap nappend ] immutable ;
M: f concat ;
M: cons concat
unswons [ swap [ nappend ] each-with ] immutable ;
M: object concat
>list concat ;
: concat ( seq -- seq )
#! Append a sequence of sequences together. The new sequence
#! has the same type as the first sequence.
dup empty? [
[ 1024 <vector> swap [ dupd nappend ] each ] keep
first like
] unless ;
M: object peek ( sequence -- element )
#! Get value at end of sequence.

View File

@ -196,7 +196,7 @@ M: #values can-kill* ( literal node -- ? )
] ifte ;
: branch-values ( branches -- )
[ last-node node-in-d >list ] map
[ last-node node-in-d ] map
unify-lengths seq-transpose branch-returns set ;
: can-kill-branches? ( literal node -- ? )

View File

@ -5,11 +5,8 @@ USING: generic interpreter kernel lists math namespaces
sequences words ;
: literal-inputs? ( in stack -- )
tail-slice* dup >list [ safe-literal? ] all? [
length #drop node, t
] [
drop f
] ifte ;
tail-slice* dup [ safe-literal? ] all?
[ length #drop node, t ] [ drop f ] ifte ;
: literal-inputs ( out stack -- )
tail-slice* [ literal-value ] nmap ;

View File

@ -1,5 +1,6 @@
IN: temporary
USING: kernel lists math matrices namespaces sequences test ;
USING: kernel lists math matrices namespaces sequences test
vectors ;
[ [ [ 1 4 ] [ 2 5 ] [ 3 6 ] ] ]
[ M[ [ 1 4 ] [ 2 5 ] [ 3 6 ] ]M row-list ] unit-test
@ -131,10 +132,10 @@ unit-test
] unit-test
[
[ [ 7 ] [ 4 8 ] [ 1 5 9 ] [ 2 6 ] [ 3 ] ]
[ { 7 } { 4 8 } { 1 5 9 } { 2 6 } { 3 } ]
] [
M[ [ 1 2 3 ] [ 4 5 6 ] [ 7 8 9 ] ]M
5 [ 2 - swap <diagonal> ] project-with [ >list ] map
5 [ 2 - swap <diagonal> ] project-with [ >vector ] map
] unit-test
[ { t t t } ]

View File

@ -1,11 +1,11 @@
IN: temporary
USING: kernel lists math sequences strings test vectors ;
[ [ 1 2 3 4 ] ] [ 1 5 <range> >list ] unit-test
[ { 1 2 3 4 } ] [ 1 5 <range> >vector ] unit-test
[ 3 ] [ 1 4 <range> length ] unit-test
[ [ 4 3 2 1 ] ] [ 4 0 <range> >list ] unit-test
[ { 4 3 2 1 } ] [ 4 0 <range> >vector ] unit-test
[ 2 ] [ 1 3 { 1 2 3 4 } <slice> length ] unit-test
[ [ 2 3 ] ] [ 1 3 { 1 2 3 4 } <slice> >list ] unit-test
[ { 2 3 } ] [ 1 3 { 1 2 3 4 } <slice> >vector ] unit-test
[ { 4 5 } ] [ 2 { 1 2 3 4 5 } tail-slice* >vector ] unit-test
[ { 1 2 } { 3 4 } ] [ 2 { 1 2 3 4 } cut ] unit-test
[ { 1 2 } { 4 5 } ] [ 2 { 1 2 3 4 5 } cut* ] unit-test

View File

@ -1,4 +1,5 @@
IN: temporary
USING: vectors ;
USE: errors
USE: kernel
USE: math
@ -96,4 +97,4 @@ unit-test
[ 1 "" nth ] unit-test-fails
[ -6 "hello" nth ] unit-test-fails
[ t ] [ "hello world" dup >list >string = ] unit-test
[ t ] [ "hello world" dup >vector >string = ] unit-test

View File

@ -11,8 +11,8 @@ global [ 100 <vector> commands set ] bind
: define-command ( class name quot -- )
3list commands get push ;
: applicable ( object -- list )
commands get >list [ car call ] subset-with ;
: applicable ( object -- seq )
commands get [ car call ] subset-with ;
: command-quot ( presented quot -- quot )
[ swap literal, % ] make-list