Funny lambda with variable arguments count behavior
Funny (lambda . args) behavior when self returning.
You see a prompt.
> (define (subloop . args) (cons 123 args))
;; Defined subloop
> (apply subloop '(1 2 3))
'(123 1 2 3)
> (define (subloop . args) (cons subloop args))
;; Defined subloop
> (apply subloop '(1 2 3))
(error: arity-error reported error: #<function> (subloop) #[#<function> 1 2 3])
Failed to evaluate (apply subloop '(1 2 3)) because an error occurred
Found during making a function that recursively process vector of vectors. As a workaround can be used subfunction that can be applyied. Sample code:
(let loop ((arrays arrays))
(define (reloop . args) (loop args))
(if (vector? (ref (car arrays) 1))
(apply vector-map (cons reloop arrays)) ; instead of (cons loop arrays)
(apply vector-map (cons f arrays)))))
Edited by Uri