20-CS-4003-001 Organization of Programming Languages Fall 2017
Operations

Lambda calculus, Type theory, Formal semantics, Program analysis

    Prev     Next     All lectures           Code

Miscellaneous Operations

   
a1 = max 78 43  -  a1 is 78
a2 = min 78 43  -  a2 is 43
a3 = "Hello" ++ "World"  -  a3 is "HelloWorld"
a4 = "Hello" !! 2  -  a4 is 'l' (strings are lists of characters)
a5 = [odd 3, odd 4]  -  a5 is [True,False] (ask whether a number is odd)
a6 = [even 3, even 4]  -  a6 is [False,True] (ask whether a number is even)
a7 = zip [1,2,3,4] [5,6,7,8]  -  a7 is [(1,5),(2,6),(3,7),(4,8)] (zips two lists into a list of pairs)
a8 = (succ 'a', succ 1)  -  a8 is ('b',2) (next symbol in order, tuple elements may have different types)