dup function request

Q&A's, tips, howto's
Locked
eddier
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

dup function request

Post by eddier »

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

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

For the string repeat we had some discussion here:

http://www.alh.net/newlisp/phpbb/viewto ... epstr#1705

http://www.alh.net/newlisp/phpbb/viewto ... ght=repstr

A generic dup sounds usefull to me.
Hans-Peter

eddier
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Post by eddier »

Thanks for the addition :)

Eddie

Locked