Change cut stack effect
parent
c5f760da65
commit
4192413861
|
@ -53,7 +53,7 @@ M: effect clone
|
||||||
[ effect-in clone ] keep effect-out clone <effect> ;
|
[ effect-in clone ] keep effect-out clone <effect> ;
|
||||||
|
|
||||||
: split-shuffle ( stack shuffle -- stack1 stack2 )
|
: split-shuffle ( stack shuffle -- stack1 stack2 )
|
||||||
effect-in length swap cut* ;
|
effect-in length cut* ;
|
||||||
|
|
||||||
: load-shuffle ( stack shuffle -- )
|
: load-shuffle ( stack shuffle -- )
|
||||||
effect-in [ set ] 2each ;
|
effect-in [ set ] 2each ;
|
||||||
|
|
|
@ -296,7 +296,7 @@ M: phantom-retainstack finalize-height
|
||||||
GENERIC: cut-phantom ( n phantom -- seq )
|
GENERIC: cut-phantom ( n phantom -- seq )
|
||||||
|
|
||||||
M: phantom-stack cut-phantom
|
M: phantom-stack cut-phantom
|
||||||
[ delegate cut* swap ] keep set-delegate ;
|
[ delegate swap cut* swap ] keep set-delegate ;
|
||||||
|
|
||||||
: phantom-append ( seq stack -- )
|
: phantom-append ( seq stack -- )
|
||||||
over length over adjust-phantom push-all ;
|
over length over adjust-phantom push-all ;
|
||||||
|
|
|
@ -120,7 +120,7 @@ SYMBOL: ->
|
||||||
|
|
||||||
: remove-breakpoints ( quot pos -- quot' )
|
: remove-breakpoints ( quot pos -- quot' )
|
||||||
over quotation? [
|
over quotation? [
|
||||||
1+ swap cut [ (remove-breakpoints) ] 2apply
|
1+ cut [ (remove-breakpoints) ] 2apply
|
||||||
[ -> ] swap 3append
|
[ -> ] swap 3append
|
||||||
] [
|
] [
|
||||||
drop
|
drop
|
||||||
|
|
|
@ -904,17 +904,17 @@ HELP: tail?
|
||||||
{ delete-nth remove delete } related-words
|
{ delete-nth remove delete } related-words
|
||||||
|
|
||||||
HELP: cut-slice
|
HELP: cut-slice
|
||||||
{ $values { "n" "a non-negative integer" } { "seq" sequence } { "before" sequence } { "after" "a slice" } }
|
{ $values { "seq" sequence } { "n" "a non-negative integer" } { "before" sequence } { "after" "a slice" } }
|
||||||
{ $description "Outputs a pair of sequences, where " { $snippet "before" } " consists of the first " { $snippet "n" } " elements of " { $snippet "seq" } " and has the same type, while " { $snippet "after" } " is a slice of the remaining elements." }
|
{ $description "Outputs a pair of sequences, where " { $snippet "before" } " consists of the first " { $snippet "n" } " elements of " { $snippet "seq" } " and has the same type, while " { $snippet "after" } " is a slice of the remaining elements." }
|
||||||
{ $notes "Unlike " { $link cut } ", the run time of this word is proportional to the length of " { $snippet "before" } ", not " { $snippet "after" } ", so it is suitable for use in an iterative algorithm which cuts successive pieces off a sequence." } ;
|
{ $notes "Unlike " { $link cut } ", the run time of this word is proportional to the length of " { $snippet "before" } ", not " { $snippet "after" } ", so it is suitable for use in an iterative algorithm which cuts successive pieces off a sequence." } ;
|
||||||
|
|
||||||
HELP: cut
|
HELP: cut
|
||||||
{ $values { "n" "a non-negative integer" } { "seq" sequence } { "before" sequence } { "after" sequence } }
|
{ $values { "seq" sequence } { "n" "a non-negative integer" } { "before" sequence } { "after" sequence } }
|
||||||
{ $description "Outputs a pair of sequences, where " { $snippet "before" } " consists of the first " { $snippet "n" } " elements of " { $snippet "seq" } ", while " { $snippet "after" } " holds the remaining elements. Both output sequences have the same type as " { $snippet "seq" } "." }
|
{ $description "Outputs a pair of sequences, where " { $snippet "before" } " consists of the first " { $snippet "n" } " elements of " { $snippet "seq" } ", while " { $snippet "after" } " holds the remaining elements. Both output sequences have the same type as " { $snippet "seq" } "." }
|
||||||
{ $notes "Since this word copies the entire tail of the sequence, it should not be used in a loop. If this is important, consider using " { $link cut-slice } " instead, since it returns a slice for the tail instead of copying." } ;
|
{ $notes "Since this word copies the entire tail of the sequence, it should not be used in a loop. If this is important, consider using " { $link cut-slice } " instead, since it returns a slice for the tail instead of copying." } ;
|
||||||
|
|
||||||
HELP: cut*
|
HELP: cut*
|
||||||
{ $values { "n" "a non-negative integer" } { "seq" sequence } { "before" sequence } { "after" sequence } }
|
{ $values { "seq" sequence } { "n" "a non-negative integer" } { "before" sequence } { "after" sequence } }
|
||||||
{ $description "Outputs a pair of sequences, where " { $snippet "after" } " consists of the last " { $snippet "n" } " elements of " { $snippet "seq" } ", while " { $snippet "before" } " holds the remaining elements. Both output sequences have the same type as " { $snippet "seq" } "." } ;
|
{ $description "Outputs a pair of sequences, where " { $snippet "after" } " consists of the last " { $snippet "n" } " elements of " { $snippet "seq" } ", while " { $snippet "before" } " holds the remaining elements. Both output sequences have the same type as " { $snippet "seq" } "." } ;
|
||||||
|
|
||||||
HELP: start*
|
HELP: start*
|
||||||
|
|
|
@ -604,14 +604,14 @@ M: sequence <=>
|
||||||
tuck length tail-slice* sequence=
|
tuck length tail-slice* sequence=
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: cut-slice ( n seq -- before after )
|
: cut-slice ( seq n -- before after )
|
||||||
swap [ head ] 2keep tail-slice ;
|
[ head ] 2keep tail-slice ;
|
||||||
|
|
||||||
: cut ( n seq -- before after )
|
: cut ( seq n -- before after )
|
||||||
swap [ head ] 2keep tail ;
|
[ head ] 2keep tail ;
|
||||||
|
|
||||||
: cut* ( n seq -- before after )
|
: cut* ( seq n -- before after )
|
||||||
swap [ head* ] 2keep tail* ;
|
[ head* ] 2keep tail* ;
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ M: tuple class class-of-tuple ;
|
||||||
swap [ index ] curry map ;
|
swap [ index ] curry map ;
|
||||||
|
|
||||||
: reshape-tuple ( oldtuple permutation -- newtuple )
|
: reshape-tuple ( oldtuple permutation -- newtuple )
|
||||||
>r tuple>array 2 swap cut r>
|
>r tuple>array 2 cut r>
|
||||||
[ [ swap ?nth ] [ drop f ] if* ] curry* map
|
[ [ swap ?nth ] [ drop f ] if* ] curry* map
|
||||||
append (>tuple) ;
|
append (>tuple) ;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ PRIVATE>
|
||||||
: >base64 ( seq -- base64 )
|
: >base64 ( seq -- base64 )
|
||||||
#! cut string into two pieces, convert 3 bytes at a time
|
#! cut string into two pieces, convert 3 bytes at a time
|
||||||
#! pad string with = when not enough bits
|
#! pad string with = when not enough bits
|
||||||
[ length dup 3 mod - ] keep cut swap
|
dup length dup 3 mod - swap
|
||||||
[
|
[
|
||||||
3 group [ encode3 % ] each
|
3 group [ encode3 % ] each
|
||||||
dup empty? [ drop ] [ >base64-rem % ] if
|
dup empty? [ drop ] [ >base64-rem % ] if
|
||||||
|
|
|
@ -113,7 +113,7 @@ M: f print-element drop ;
|
||||||
"Examples" $heading print-element ;
|
"Examples" $heading print-element ;
|
||||||
|
|
||||||
: $example ( element -- )
|
: $example ( element -- )
|
||||||
1 swap cut* swap "\n" join dup <input> [
|
1 cut* swap "\n" join dup <input> [
|
||||||
input-style get format nl print-element
|
input-style get format nl print-element
|
||||||
] ($code) ;
|
] ($code) ;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ IN: io.sniffer.filter.bsd
|
||||||
"long" heap-size 1- [ + ] keep bitnot bitand ;
|
"long" heap-size 1- [ + ] keep bitnot bitand ;
|
||||||
|
|
||||||
M: unix-io packet. ( string -- )
|
M: unix-io packet. ( string -- )
|
||||||
18 swap cut swap >byte-array bpfh.
|
18 cut swap >byte-array bpfh.
|
||||||
(packet.) ;
|
(packet.) ;
|
||||||
|
|
||||||
M: unix-io sniffer-loop ( stream -- )
|
M: unix-io sniffer-loop ( stream -- )
|
||||||
|
|
|
@ -77,7 +77,7 @@ SYMBOL: irc-client
|
||||||
trim-: "!" split first ;
|
trim-: "!" split first ;
|
||||||
: irc-split ( string -- seq )
|
: irc-split ( string -- seq )
|
||||||
1 swap [ [ CHAR: : = ] find* ] keep
|
1 swap [ [ CHAR: : = ] find* ] keep
|
||||||
swap [ cut trim-: ] [ nip f ] if >r [ blank? ] trim trim-:
|
swap [ swap cut trim-: ] [ nip f ] if >r [ blank? ] trim trim-:
|
||||||
" " split r> [ 1array append ] when* ;
|
" " split r> [ 1array append ] when* ;
|
||||||
: me? ( name -- ? )
|
: me? ( name -- ? )
|
||||||
irc-client get irc-client-nick nick-name = ;
|
irc-client get irc-client-nick nick-name = ;
|
||||||
|
|
|
@ -34,7 +34,7 @@ linkname magic version uname gname devmajor devminor prefix ;
|
||||||
155 read-c-string* over set-tar-header-prefix ;
|
155 read-c-string* over set-tar-header-prefix ;
|
||||||
|
|
||||||
: header-checksum ( seq -- x )
|
: header-checksum ( seq -- x )
|
||||||
148 swap cut-slice 8 tail-slice
|
148 cut-slice 8 tail-slice
|
||||||
[ 0 [ + ] reduce ] 2apply + 256 + ;
|
[ 0 [ + ] reduce ] 2apply + 256 + ;
|
||||||
|
|
||||||
TUPLE: checksum-error ;
|
TUPLE: checksum-error ;
|
||||||
|
|
|
@ -98,7 +98,7 @@ PRIVATE>
|
||||||
2dup nth \ break = [
|
2dup nth \ break = [
|
||||||
nip
|
nip
|
||||||
] [
|
] [
|
||||||
>r 1+ r> cut [ break ] swap 3append
|
swap 1+ cut [ break ] swap 3append
|
||||||
] if
|
] if
|
||||||
] (step) ;
|
] (step) ;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ PRIVATE>
|
||||||
|
|
||||||
: step-into ( interpreter -- )
|
: step-into ( interpreter -- )
|
||||||
[
|
[
|
||||||
cut [
|
swap cut [
|
||||||
swap % unclip literalize , \ (step-into) , %
|
swap % unclip literalize , \ (step-into) , %
|
||||||
] [ ] make
|
] [ ] make
|
||||||
] (step) ;
|
] (step) ;
|
||||||
|
|
|
@ -93,7 +93,7 @@ M: closer process
|
||||||
|
|
||||||
: make-xml-doc ( prolog seq -- xml-doc )
|
: make-xml-doc ( prolog seq -- xml-doc )
|
||||||
dup [ tag? ] find
|
dup [ tag? ] find
|
||||||
>r assure-tags swap cut 1 tail
|
>r assure-tags cut 1 tail
|
||||||
no-pre/post no-post-tags
|
no-pre/post no-post-tags
|
||||||
r> swap <xml> ;
|
r> swap <xml> ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue