X10D
X10D

Reputation: 620

How to construct values println in racket/scheme?

How to blend the two expressions into one:

(map (lambda (x) (println x)) (gen-truth 2 '(#t #f)))

(map (lambda (x) (println (apply and-l x))) (gen-truth 2 '(#t #f)))

It would be nice to see on the same line the expression before evaluation + '=>' + result of apply. For example: ((and-l '(#t #f)) => #f)

Upvotes: 0

Views: 124

Answers (1)

Óscar López
Óscar López

Reputation: 236140

We can use printf to print and format both values. On a separate note: if you're just printing the contents of a list, it's recommended to use for-each instead of map, we don't need a list as a result. This is what I mean:

(for-each (lambda (x)
            (printf "~s => ~s~n" x (apply and-l x)))
          (gen-truth 2 '(#t #f)))

Upvotes: 2

Related Questions