Ludovic Courtès on Nostr: ;; OCaml example translated to Scheme. (use-modules (ice-9 match) (srfi srfi-71)) ...
;; OCaml example translated to Scheme.
(use-modules (ice-9 match) (srfi srfi-71))
(define (self-convolution lst)
(define (visit suffix)
(match suffix
(()
(values lst '()))
((head . tail)
(let ((input output (visit tail)))
(values (cdr input)
(cons (cons head (car input))
output))))))
(let ((_ lst (visit lst)))
lst))
(use-modules (ice-9 match) (srfi srfi-71))
(define (self-convolution lst)
(define (visit suffix)
(match suffix
(()
(values lst '()))
((head . tail)
(let ((input output (visit tail)))
(values (cdr input)
(cons (cons head (car input))
output))))))
(let ((_ lst (visit lst)))
lst))