Pack?

Started by newdep, April 25, 2008, 02:51:23 AM

Previous topic - Next topic

newdep

Lutz.. What happens here?



..It looks like a coincidence to me..





>(set 'T ("one" " two " "  three"))

>(pack "%s5" T)



" two "



> (pack "%1s7" T)



"  three"





If its not a coincidence, then how do I get to "one" ?





PS: yes its a strange way of getting to a variable ;-)
-- (define? (Cornflakes))

Lutz

#1
This is just pure coincidence of a wrong format string in your 'pack'.



This is the correct way to pack lists into an array of string pointers:


>
> (set 'T '("one" " two " " three"))
("one" " two " " three")
> (set 'adr (pack "lululu" T))
"16b1600 b16000b1600"
> (map get-string (unpack "lululu" adr))
("one" " two " " three")
>


There is also a similar example about this in the manual: http://www.newlisp.org/downloads/newlisp_manual.html#pack">http://www.newlisp.org/downloads/newlis ... .html#pack">http://www.newlisp.org/downloads/newlisp_manual.html#pack



And a pattern in the second to last table here: http://www.newlisp.org/CodePatterns.html#extending">http://www.newlisp.org/CodePatterns.html#extending