I'm a bit confused on when to use MEMO: versus $[

Practically speaking, below the words clean and wordlist need only be
computed once, and I'm not sure of the best way to do it, or what the
tradeoffs are of different approaches. I'm also not sure how to do it
completely correctly. Is there an article on this subject I missed?


USING: ascii kernel math.ranges random regexp sequences strings ;
IN: lorem


<PRIVATE

CONSTANT: text "alias consequatur aut perferendis sit voluptatem
accusantium doloremque aperiam, eaque ipsa quae ab illo inventore
veritatis et."

: clean ( -- string )  text >lower R/ [^\sA-Za-z]/ "" re-replace ;

PRIVATE>

: wordlist ( -- array )  clean R/ \s+/ re-split [ >string ] map ;

: getword ( -- string )   wordlist random ;
: getwords ( n -- array ) wordlist swap sample ;
: sentencewords (  -- array  ) 4 10 [a,b] random getwords ;
: sentencestring ( -- string ) sentencewords " " join ;

: ucfirst ( string -- string ) 1 cut [ >upper ] dip append ;
: sentence ( -- string ) sentencestring ucfirst "." append ;
: sentences ( n -- array ) [ sentence ] replicate ;
: paragraph ( -- string ) 3 7 [a,b] random sentences " " join ;
: paragraphs ( n -- array ) [ paragraph ] replicate ;

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to