by fortran77 · 5y ago · 0 comments
I almost forgot—the IF statement is an expression! You can do the following:
A ← IF B = 15 THEN 40 ELSE 99
and A will be 40 if B is 15, otherwise A will be 99. There aren't many languages I've used that have allowed this
I need to introduce this man to the wonderful world of Haskell, Erlang, and other Functional Programming Languages.condition ? value_if_true : value_if_false
It is used quite extensively in ASIC design.
Also: (def a (cond (= b 15) 40 (= b 20) 50 :else 99))
``` In [2]: b = 15; In [3]: a = 40 if b == 15 else 99; In [4]: a; Out[4]: 40; ```
``` $a = $b == 15 ? 40 : 99; ```
I think it is fair to treat a “not many languages I've used...” comment about a language feature from a 2015 review in the context of current (or, at least, available in 2015) languages, even if the review is of a 1979 product.