Add firstn-unsafe, input<sequence-unsafe
parent
6b5b839e72
commit
7094b78821
|
@ -18,6 +18,10 @@ MACRO: input<sequence ( quot -- newquot )
|
||||||
[ infer in>> ] keep
|
[ infer in>> ] keep
|
||||||
'[ _ firstn @ ] ;
|
'[ _ firstn @ ] ;
|
||||||
|
|
||||||
|
MACRO: input<sequence-unsafe ( quot -- newquot )
|
||||||
|
[ infer in>> ] keep
|
||||||
|
'[ _ firstn-unsafe @ ] ;
|
||||||
|
|
||||||
MACRO: reduce-outputs ( quot operation -- newquot )
|
MACRO: reduce-outputs ( quot operation -- newquot )
|
||||||
[ dup infer out>> 1 [-] ] dip n*quot compose ;
|
[ dup infer out>> 1 [-] ] dip n*quot compose ;
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,14 @@ MACRO: narray ( n -- )
|
||||||
MACRO: nsum ( n -- )
|
MACRO: nsum ( n -- )
|
||||||
1- [ + ] n*quot ;
|
1- [ + ] n*quot ;
|
||||||
|
|
||||||
|
MACRO: firstn-unsafe ( n -- )
|
||||||
|
[ '[ [ _ ] dip nth-unsafe ] ] map '[ _ cleave ] ;
|
||||||
|
|
||||||
MACRO: firstn ( n -- )
|
MACRO: firstn ( n -- )
|
||||||
dup zero? [ drop [ drop ] ] [
|
dup zero? [ drop [ drop ] ] [
|
||||||
[ [ '[ [ _ ] dip nth-unsafe ] ] map ]
|
[ 1- swap bounds-check 2drop ]
|
||||||
[ 1- '[ [ _ ] dip bounds-check 2drop ] ]
|
[ firstn-unsafe ]
|
||||||
bi prefix '[ _ cleave ]
|
bi-curry '[ _ _ bi ]
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
MACRO: npick ( n -- )
|
MACRO: npick ( n -- )
|
||||||
|
|
Loading…
Reference in New Issue