Paste: what am I doing wrong?
Author: | wagstaff |
Mode: | factor |
Date: | Sat, 31 Jul 2010 11:15:51 |
Plain Text |
(scratchpad) : <seq1> ( -- seq ) { 1 2 3 } ;
(scratchpad) : <seq2> ( -- seq ) { 4 5 6 } ;
(scratchpad) <seq1> seq-min .
1
(scratchpad) <seq2> seq-min .
4
(scratchpad) { { 1 2 3 } { 4 5 6 } } [ seq-min ] map .
{ 1 4 }
So far so good! But...
(scratchpad) { <seq1> <seq2> } [ seq-min ] map
"Generic word length does not define a method for the word class. Dispatching on object <seq1>"
Author: | Evgeny |
Mode: | factor |
Date: | Sat, 31 Jul 2010 16:57:38 |
Plain Text |
If you input { <seq1> <seq2> }
--- Data stack:
{ <seq1> <seq2> }
You get sequence of words. Map indefine on such sequences.
Maybe it is WAD I suppose.
Author: | Evgeny |
Mode: | factor |
Date: | Sat, 31 Jul 2010 17:09:08 |
Plain Text |
I suppose you should write instead of your code to resolve you "issue"
{ <seq1> <seq2> } [ call seq-min ] map
Author: | Evgteny |
Mode: | factor |
Date: | Sat, 31 Jul 2010 17:29:17 |
Plain Text |
It is no problem for map - it is problem for seq-min word.
map applies quotation on each element of sequence. In your case it tries to apply seq-min for <seq1>. Instead you should write [ call seq-min ] to resolve: map apply first call to <seq1> and then seq-min to getting sequence.
New Annotation