C++ to D

Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 11 10:27:27 PDT 2015


The same without classes in Lisp:

(define (foo)
   (let ((foo1 (lambda (s) s))
         (foo2 (lambda (s) (list->string (reverse (string->list 
s)))))
         (foo3 (lambda (s) (string-append s ", " s " "))))
     (lambda (in)
       (match in
         ("first" foo1)
         ("second" foo2)
         ("third" foo3)
         (_ void)))))

(define (main)
   (define bar (foo))

   (for/list ([i '("first" "second" "third")])
     ((bar i) "poor c++")))


More information about the Digitalmars-d-learn mailing list