23 Apr 23:15
What is a good definition ?
From: Jean-François Bigot <jeff.bigot@...>
Subject: What is a good definition ?
Newsgroups: gmane.comp.lang.factor.general
Date: 2008-04-23 21:17:06 GMT
Subject: What is a good definition ?
Newsgroups: gmane.comp.lang.factor.general
Date: 2008-04-23 21:17:06 GMT
Hi,
I needed to get the list of all combinaisons of n elements chosen in
a sequence.
Quite simple in fact but disturbing for a beginner.
First problem, how to know if there is already a word doing this in
factor?
RTFM => I read "Sequence operations" several times.
Documentation is very nice and interesting to read but it's sometime
difficult for me to find a word doing what I want.
(Or there are too many words doing quite the same, I don't know)
Nevertheless reading definitions often give new ideas on how to
solve problems.
Second problem, maybe the needed word is undocumented somewhere in
the extra directory.
In that case it's maybe simpler to rewrite than to try to find it.
With doc freshly reminded I wrote without too many difficulties the
next two definitions (lean back and think)
: columnize ( seq -- seq )
[ 1array ] map
; inline
: among ( seq n -- seq )
2dup swap length
{
(Continue reading)
RSS Feed