Hi Gareth, Your code can just be:
{ 24 8 2004 } first3 spin <date> To make the code you posted work, you have to inline all the words that call ``call'' explicitly -- aday>tuple, etc. Also, you're using each with an unknown stack effect in the last word. I'd suggest you just don't do it this way, but if you want to understand better, read "call" help and related sections. Doug On Jun 10, 2009, at 8:32 AM, Gareth Morgan wrote: > Hi. I've been trying to refactor some code to remove repetition. > Essentially I am trying to convert a date of the form { day month > year } to a timestamp. Originally I had something that looks like this > > : el-to-tuple-quot ( n acc -- quot ) > '[ dup -rot _ swap nth _ call swap ] ; inline > > : aday>tuple ( timestamp num-seq -- timestamp num-seq ) > 0 [ >>day ] el-to-tuple-quot call ; > > : amonth>tuple ( timestamp num-seq -- timestamp num-seq ) > 1 [ >>month ] el-to-tuple-quot call ; > > : ayear>tuple ( timestamp num-seq -- timestamp num-seq ) > 2 [ >>year ] el-to-tuple-quot call ; > > : num-date>timestamp ( num-seq -- timestamp ) > T{ timestamp } swap aday>tuple amonth>tuple > ayear>tuple drop ; > > I decided that the 'a*>tuple' words were unnecessary and could be > replaced with an each call > > : el-to-tuple-quot ( n acc -- quot ) > '[ dup -rot _ swap nth _ call swap ] ; inline > > : array-to-tuple-quot ( -- quot ) > [ first2 el-to-tuple-quot call ] ; inline > > : num-date>timestamp ( num-seq -- timestamp ) > T{ timestamp } swap > { { 0 [ >>day ] } { 1 [ >>month ] } { 2 [ >>year ] } } > array-to-tuple-quot each drop ; > > However I now get the 'Got a computed value where a literal > quotation was expected; ' error. It works fine when called directly > on the listener but doesn't when running from a vocabulary. I've > tried replacing both words that return quots with their definitions > but get the same error. I've also tried fiddling with the inline > calls to see if I can get it to work. Anyone know what is going on? > > Cheers, > Gareth > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables unlimited > royalty-free distribution of the report engine for externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects_______________________________________________ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk