Skip to content

Instantly share code, notes, and snippets.

@ytaki0801
Last active December 24, 2021 08:02
Show Gist options
  • Save ytaki0801/4ce2f5390e265b0bb11970a19f3ee7df to your computer and use it in GitHub Desktop.
Save ytaki0801/4ce2f5390e265b0bb11970a19f3ee7df to your computer and use it in GitHub Desktop.
;;;; referense
;;;; SLIB 3b1-5
;;;; Gauche 0.9.11
;;;; MIT/GNU Scheme 11.2
(define (reduce-right f ridentity ls)
(if (null? ls) ridentity
(let loop ((ridentity (car ls)) (ls (cdr ls)))
(if (null? ls) ridentity
(f ridentity (loop (car ls) (cdr ls)))))))
;;;; Guile 3.0.7
(define (reduce-right f ridentity ls)
(if (null? ls) ridentity
(fold-right f (last ls) (drop-right ls 1))))
;;;; Chibi-Scheme 0.10.0
(define (reduce-right f ridentity ls)
(if (null? ls) ridentity
(fold-right f ridentity ls)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment