Concepts of Programming Languages
700 Chapter 15 Functional Programming Languages similar in these regards to C++ and C#. Its basis, however, is the original LISP ...
15.7 ML 701 This expression evaluates to (a (* 3 4) c). However, the following expression: `(a ,(* 3 4) c) evaluates to (a 12 c) ...
702 Chapter 15 Functional Programming Languages strongly typed language, whereas Scheme is essentially typeless. ML has type dec ...
15.7 ML 703 the type of the parameter and the function are assumed to be numeric. In ML, the default numeric type is int. So, it ...
704 Chapter 15 Functional Programming Languages parameter are separated by an OR symbol (|). For example, using pattern matching ...
15.7 ML 705 can. Actually, if you do rebind a name with a second val statement, it causes a new entry in the evaluation environm ...
706 Chapter 15 Functional Programming Languages ML has a binary operator for composing two functions, o (a lowercase “oh”). For ...
15.8 Haskell 707 Curried functions also can be written in Scheme, Haskell, and F#. Con- sider the following Scheme function: (DE ...
708 Chapter 15 Functional Programming Languages Using pattern matching, we can define a function for computing the nth Fibonacci ...
15.8 Haskell 709 Notice that the : operator is just like ML’s :: operator.^12 Using : and pattern matching, we can define a simp ...
710 Chapter 15 Functional Programming Languages specify the infix use of these functions. When they are called in functional not ...
15.8 Haskell 711 wanted to know if a particular number was a perfect square, we could check the squares list with a membership f ...
712 Chapter 15 Functional Programming Languages terminates. So, under lazy evaluation, g runs as little as possible. This evalua ...
15.9 F# 713 defines y to be a very long sequence, but only the needed elements are gener- ated. For display, only the first four ...
714 Chapter 15 Functional Programming Languages lambda expressions, they are defined with the fun reserved word. The follow- ing ...
15.10 Support for Functional Programming in Primarily Imperative Languages 715 |> List.filter (fun n −> n % 2 = 0) |> L ...
716 Chapter 15 Functional Programming Languages An anonymous function is defined in JavaScript with the same syntax, except that ...
15.11 A Comparison of Functional and Imperative Languages 717 Following is an example of using times: x = times.(3, 4) This sets ...
718 Chapter 15 Functional Programming Languages nor do they take the same amount of time to produce. In fact, because of the nec ...
15.11 A Comparison of Functional and Imperative Languages 719 This version simply specifies three steps: Build the list of numb ...
«
32
33
34
35
36
37
38
39
40
41
»
Free download pdf