Main Menu

dup

Started by Jeremy Dunn, February 06, 2009, 11:51:07 AM

Previous topic - Next topic

Jeremy Dunn

dup
Lutz,



Why not make DUP take additional multiplier arguments so that

(dup x n1 n2 n3 ....) is the same as (dup (dup (dup x n1) n2) n2)? That way if I want a 3x3 matrix of zeros I can write (dup 0 3 3) instead of (dup (dup 0 3) 3).

newBert

#1
Maybe you can do also:
(dup (series 0 0 3) 3)
;-> ((0 0 0) (0 0 0) (0 0 0))


Quote from: "Manual and Reference" (series num-start num-factor num-count)

In the first syntax, series creates a geometric sequence with num-count elements starting with the element in num-start. Each subsequent element is multiplied by num-factor.


P.S.: sorry, i just realize that it amounts to the same thing :-/
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

newBert

#2
Try this way instead:
> (array 3 3 '(0))
((0 0 0) (0 0 0) (0 0 0))

;o)
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>