Hi Alex,

I hope I'm not being too pedantic here, but...

Your code still works, though I want to remove unique eventually in
favor of <hash-set> (or HS{ } set-like). A higher-level way to express
"unique values" is to use the word "members". Before the change to the
set protocol, you'd use "prune", which is similar but specific to
sequences (which you're using here). A minor difference between
members on sequences and prune is that members tries to return a
sequence of the same type as the input, whereas prune returns a
vector.

Dan

On Fri, Mar 19, 2010 at 7:15 AM, Alex Chapman <[email protected]> wrote:
> Hi anyone who's interested,
>
> I was frustrated by a word puzzle in a newspaper which in Factor can
> be stated as:
>
> Find a permutation of the string "mtnymisei" which is a valid English word.
>
> I gave up doing it in my head so I opened up Factor to solve it for
> me. I needed a list of valid English words which I got from aspell:
>
> cd ~/tmp
> wget http://ftp.gnu.org/gnu/aspell/dict/en/aspell6-en-6.0-0.tar.bz2
> tar xjvf aspell6-en-6.0-0.tar.bz2
> cd aspell6-en-6.0-0
> preunzip en-common.cwl # outputs en-common.wl which is a
> newline-separated list of words
>
> The easy part was Factor:
> "mtnymisei" all-permutations unique values [ >string ] map ! leaves a
> seq of the 90720 strings which are unique combinations of "mtnymisei"
> "/Users/ajc/tmp/aspell6-en-6.0-0/en-common.wl" ascii [ lines ]
> with-file-reader ! leaves a seq of valid English words
> intersect
>
> ... and that's it! I'm left with an array containing the one word that fits :)
>
> Of course my path to the solution wasn't quite such a fairy tale, but
> it only took around 30 minutes in total, and most of that was trying
> to find a valid word list. I originally tried to print each
> permutation in the listener, but that kept crashing Factor.
>
> Anyway, I had fun so I thought I'd share. Apologies to littledan if
> I'm not using the latest set protocol words, I haven't updated in a
> week or so.
>
> Alex
>
> ------------------------------------------------------------------------------
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to