EWTD

Untitled

Sep 22nd, 2020
1,245
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ------------Лаба---------------
  2. (define (o . funcs)
  3.   (define (_iter funcs)
  4.     (if (not (null? (cdr funcs)))
  5.         (lambda (x) ((car funcs)((_iter (cdr funcs)) x)))
  6.         (lambda (x) ((car funcs) x))))
  7.   (if (null? funcs)
  8.       (lambda (x) x)
  9.       (_iter funcs)))
  10. -----------ДЗ----------------
  11. (define (my-fold-right callable collectable)
  12.   (define default-value #f)
  13.   (define (_iter collectable res)
  14.     (if (not (null? collectable))
  15.         (if (equal? res default-value)
  16.             (if (not (null? (cdr collectable)))
  17.                 (_iter (cddr collectable) (callable (cadr collectable) (car collectable)))
  18.                 (car collectable))
  19.             (_iter (cdr collectable) (callable (car collectable) res)))
  20.         res))
  21.   (_iter (reverse collectable) default-value))
  22.  
  23. (define (o . funcs)
  24.   (define (comb f1 f2)
  25.     (lambda (x) (f1 (f2 x))))
  26.   (if (null? funcs)
  27.       (lambda (x) x)
  28.       (my-fold-right comb funcs)))
RAW Paste Data