4 ms·
> A ton of responses and no one mentions the one-word answer? Statements like "You can easily do this is Ruby" hint that author understood exactly nothing and
by adobriyan 15y ago
> A ton of responses and no one mentions the one-word answer?
Statements like "You can easily do this is Ruby" hint that author understood exactly nothing and focused on some random uninteresting example code while missing big picture.
Does Ruby have COND?
If it doesn't, can one implement it using existing Ruby constructs?
If it does, can one implement it using existing Ruby constructs except COND?
- lattepiu 15y agoI don't believe this is a good example. Ruby has case..when instead of COND, though it's a language construct, not a function; but I think COND can be trivially implemented in any language that has anonymous functions. In Ruby: def COND(*args) args.each_slice(2){ |s| return s[1].call if s[0].call } end COND(lambda{ false }, lambda{ "not this"}, lambda{ true }, lambda{ "this" }) (not a lisper, though, so I might be missing something).