История изменений
Исправление Nervous, (текущая версия) :
(define xs '(1 2 3))
(define ys '(3 2 1))
;; divide all the elements of xs by all the elements of ys
(define cartesian-division
(lambda (xs ys)
(flatten (map (lambda (x)
(map (lambda (y)
(/ x y)) ys)) xs))))
;; negate all the elements of xs and append them to xs
(define negate-and-append
(lambda (xs)
(let ((negated-xs (map - xs)))
(append xs negated-xs))))
(negate-and-append (cartesian-division xs ys))
Неужели в наших вузах где-то учат лиспам?
Исправление Nervous, :
(define xs '(1 2 3))
(define ys '(3 2 1))
;; divide all the elements of xs by all the elements of ys
(define cartesian-division
(lambda (xs ys)
(flatten (map (lambda (x)
(map (lambda (y)
(/ x y)) ys)) xs))))
;; negate all the elements of xs and append them to xs
(define negate-and-append
(lambda (xs)
(let ((inverted-xs (map - xs)))
(append xs inverted-xs))))
(negate-and-append (cartesian-division xs ys))
Неужели в наших вузах где-то учат лиспам?
Исходная версия Nervous, :
(define xs '(1 2 3))
(define ys '(3 2 1))
;; divide all the elements of xs by all the elements of ys
(define cartesian-division
(lambda (xs ys)
(flatten (map (lambda (x)
(map (lambda (y)
(/ x y)) ys)) xs))))
;; negate all the elements of xs and append them to xs
(define negate-and-append
(lambda (xs)
(let ((inverted-xs (map - xs)))
(append xs inverted-xs))))
(invert-and-append (cartesian-division xs ys))
Неужели в наших вузах где-то учат лиспам?