Sha256: 4653a16ea6c96cce2c2c91779cabcc3ae54d4bdacadb96226d246eabc6ae6d84
Contents?: true
Size: 1.11 KB
Versions: 396
Compression:
Stored size: 1.11 KB
Contents
(define-module (list-ops) #:export (my-length ; Avoid overriding core bindings my-reverse my-map my-filter my-fold my-append my-concatenate )) (define (my-length l) (define (go l acc) (if (null? l) acc (go (cdr l) (+ 1 acc)))) (go l 0)) (define (my-reverse l) (define (go l acc) (if (null? l) acc (go (cdr l) (cons (car l) acc)))) (go l '())) (define (my-map f l) (define (go l acc) (if (null? l) (my-reverse acc) (go (cdr l) (cons (f (car l)) acc)))) (go l '())) (define (my-filter f l) (define (go l acc) (if (null? l) (my-reverse acc) (if (f (car l)) (go (cdr l) (cons (car l) acc)) (go (cdr l) acc)))) (go l '())) (define (my-fold f acc l) (if (null? l) acc (my-fold f (f (car l) acc) (cdr l)))) (define (my-append a b) (define (go l acc) (if (null? l) acc (go (cdr l) (cons (car l) acc)))) (go (my-reverse a) b)) (define (my-concatenate ll) (my-fold my-append '() (my-reverse ll)))
Version data entries
396 entries across 396 versions & 1 rubygems