Name:
Anonymous
2013-03-21 17:48
But I don't really know how to write idiomatic code. Is anyone here willing to rewrite some of my python code, so I can see how it's done?
Also, what is the code-tag on this board?
Name:
Anonymous
2013-03-22 2:46
no libraries, but at least you can reinvent the wheels with style.
(define (product . args)
(cond ((null? args) '()) ;; invalid call, really.
((null? (cdr args)) (map list (car args))) ;; make singletons
(else (let* ((rest-products (apply product (cdr args)))
(front-list (car args))
(grouped-products (map (lambda (front-elem)
(map (lambda (rest-product)
(cons front-elem rest-product))
rest-products))
front-list)))
(apply append grouped-products)))))
It's not very fast though. Use Haskell instead.