newLISP Fan Club

Forum => newLISP in the real world => Topic started by: eddier on July 20, 2004, 02:24:59 PM

Title: dup function request
Post by: eddier on July 20, 2004, 02:24:59 PM
Lutz,



I know you've been working away here lately but, I wonder if you could add a (dup function. In almost every program I write, I duplicate something: a string, list, symbol, number, etc. An example of a function is:



(dup "ab" 0) => ""

(dup "ab" 3) => "ababab"

(dup '(1 2 3) 0) => ()

(dup '(1 2 3) 3) => ((1 2 3) (1 2 3) (1 2 3))

(dup 4 0) => ()

(dup 4 3) => (4 4 4)

(dup ab 0) => ()

(dup ab 3) => (ab ab ab)



Would anyone else like to see this added? Would you like to call it something else?



Eddie
Title:
Post by: HPW on July 20, 2004, 10:27:18 PM
For the string repeat we had some discussion here:



http://www.alh.net/newlisp/phpbb/viewtopic.php?p=1705&highlight=repstr#1705



http://www.alh.net/newlisp/phpbb/viewtopic.php?t=283&highlight=repstr



A generic dup sounds usefull to me.
Title:
Post by: eddier on July 21, 2004, 10:29:07 AM
Thanks for the addition :)



Eddie