This code appears to be equivalent to using Maybe in Haskell, with the same kind of indentation issues:

case char-width of
  Nothing -> Nothing
  Just n -> do stuff, get new Maybe, case new-maybe of
     Nothing -> Nothing
     Just x -> do stuff ... etc...

In Haskell, one composes these with bind, which combines the "do stuff" portion with the unwrapped Just value, otherwise continues returning false forever (which due to laziness is the same as the first cond returning #f).

In Racket, one could implement either monads altogether or specifically one to handle chaining functions that might return #f.

e.g., instead of cond:

(maybe
   (do something)
   (bind new possibly false value)
   (do something with that value)
   etc.)
____________________
 Racket Users list:
 http://lists.racket-lang.org/users

Reply via email to