std-make-list | ![]() |
STD-MAKE-LIST
creates a list with n elements which are initialized to def.
If def is a function the elements are added to the front dynamically, the function is evaluated for every single new element. The function may not be quoted otherwise a list of functions will be created not a list of evaluated function values.
static defaults:
(std-make-list 3 nil) => (nil nil nil) (std-make-list 3 0.0) => (0.0 0.0 0.0) (std-make-list 3 '(std-random 10)) => ((std-random 10) (std-random 10) (std-random 10))
dynamic defaults:
(std-make-list 10 'std-%random)
; or
(std-make-list 10 (function std-%random))
list of 10 real numbers between 0.0 and 1.0
=>
(std-make-list 10 '(lambda ()(std-random 10))
; or
(std-make-list 10 (function (lambda ()(std-random 10)))
list of 10 ints between 0-9
=>
(setq l 0) (std-make-list 10 '(lambda ()(setq l (1+ l))))
=> (10 9 8 7 6 5 4 3 2 1)
n: a positive integer.
def: any valid lisp expression. If it is a function or lambda list the function is guaranteed to be freshly called for every single entry from the back to the front.
A list of n elements. Every element has the value of def, which is evaluated for every element if it's a function or lambda list, returns T for STD-FUNCTIONP.
def is evaluated n times if it is a function. This may cause side-effects.
(std-require 'STDLIST)
Defined in STDLIST