sequences.lib: Add each-percent

db4
Eduardo Cavazos 2008-04-08 02:25:14 -05:00
parent 042b5ece23
commit 9430478503
1 changed files with 10 additions and 0 deletions

View File

@ -37,6 +37,16 @@ MACRO: firstn ( n -- )
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: each-percent ( seq quot -- )
>r
dup length
dup [ / ] curry
[ 1+ ] swap compose
r> compose
2each ; inline
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: sigma ( seq quot -- n )
[ rot slip + ] curry 0 swap reduce ; inline