sequences, tetris, rosetta-code: Simplify some code.
parent
247f57b828
commit
15d720458a
|
@ -26,12 +26,8 @@ MEMO: word-list ( -- seq )
|
|||
: ordered-word? ( word -- ? )
|
||||
>lower 2 <clumps> [ first2 <= ] all? ;
|
||||
|
||||
: filter-longest-words ( seq -- seq' )
|
||||
dup [ length ] [ max ] map-reduce
|
||||
'[ length _ = ] filter ;
|
||||
|
||||
: ordered-words-main ( -- )
|
||||
word-list [ ordered-word? ] filter
|
||||
filter-longest-words [ print ] each ;
|
||||
all-longest [ print ] each ;
|
||||
|
||||
MAIN: ordered-words-main
|
||||
|
|
|
@ -51,7 +51,7 @@ M:: offset modified-set-nth ( elt n seq -- )
|
|||
TUPLE: summed < modified seqs ;
|
||||
C: <summed> summed
|
||||
|
||||
M: summed length seqs>> [ length ] [ max ] map-reduce ;
|
||||
M: summed length seqs>> longest length ;
|
||||
|
||||
<PRIVATE
|
||||
: ?+ ( x/f y/f -- sum )
|
||||
|
|
|
@ -104,7 +104,7 @@ SYMBOL: tetrominoes
|
|||
tetrominoes get random ;
|
||||
|
||||
: blocks-max ( blocks quot -- max )
|
||||
map [ 1 + ] [ max ] map-reduce ; inline
|
||||
map supremum 1 + ; inline
|
||||
|
||||
: blocks-width ( blocks -- width )
|
||||
[ first ] blocks-max ;
|
||||
|
|
Loading…
Reference in New Issue