4 ms·
FORTRAN I and II then had only an Arithmetic IF statement with three labels to jump to, based on an arithmetic value ( https://en.wikipedia.org/wiki/Arithmetic
by lispm 4y ago
FORTRAN I and II then had only an Arithmetic IF statement with three labels to jump to, based on an arithmetic value ( https://en.wikipedia.org/wiki/Arithmetic_IF https://en.wikipedia.org/wiki/Arithmetic_IF ).
FORTRAN example:
IF ( N ) 10, 20, 30
Above means:
if N is less than zero, then jump to label 10
if N is zero, then jump to label 20
if N is greater than zero, then jump to label 30
LISP had a COND expression, with multiple condition clauses. An example with three clauses.
(COND ((= x 1) 'one)
((= x 2) 'two)
(T 'not-one-or-two))
if X is 1, then return ONE
if X is 2, then return TWO
ELSE return NOT-ONE-OR-TWO
John McCarthy mentions conditional expressions in this paper from 1958: https://www.softwarepreservation.org/projects/LISP/MIT/AIM-001.pdf https://www.softwarepreservation.org/projects/LISP/MIT/AIM-0...
In external LISP syntax a COND would have looked similar to this:
(x>1 -> 1, x=0 -> 0, x<1 -> -1)
Above would mean:
if X greater than 1, then return 1
if X is 0, then return 0
if X is smaller than 1, then return -1