FWIW I like expressing this with pattern matching:
#lang racket/base
(require racket/match)
(struct node (left right))
(define (lines a-node)
(match a-node
[(node #f #f) 'neither]
[(node left #f) left]
[(node #f right) right]
[(node left right) (list left right)]))
(module+ test
(require rackunit)
(check-equal? (lines (node #f #f)) 'neither)
(check-equal? (lines (node 'left #f)) 'left)
(check-equal? (lines (node #f 'right)) 'right)
(check-equal? (lines (node 'left 'right)) '(left right)))
Note that the order of the four `match` clauses matters, in the same
way Matthew described for `cond`.
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.