Concepts of Programming Languages
680 Chapter 15 Functional Programming Languages functions to names so that functions could be referenced by other functions and ...
15.5 An Introduction to Scheme 681 15.5 An Introduction to Scheme In this section, we describe the core part of Scheme (Dybvig, ...
682 Chapter 15 Functional Programming Languages its parameters together. / and − can have two or more parameters. In the case of ...
15.5 An Introduction to Scheme 683 never changes in the expression after being bound to an actual parameter value at the time ev ...
684 Chapter 15 Functional Programming Languages (DEFINE (function_name parameters) (expression) ) Of course, this form of DEFINE ...
15.5 An Introduction to Scheme 685 15.5.6 Numeric Predicate Functions A predicate function is one that returns a Boolean value ( ...
686 Chapter 15 Functional Programming Languages For example, (DEFINE (factorial n) (IF (<= n 1) 1 (* n (factorial (− n 1))) ) ...
15.5 An Introduction to Scheme 687 In the remainder of this chapter, the common abbreviation of the call to QUOTE is used, which ...
688 Chapter 15 Functional Programming Languages equivalent to (CAR (CDR (CDR (CAR x)))). Any combination of A’s and D’s, up to f ...
15.5 An Introduction to Scheme 689 returns (apple orange grape) Using CONS, the call to LIST above is written as follows: (CONS ...
690 Chapter 15 Functional Programming Languages are the same symbols (because Scheme does not make duplicates of symbols); other ...
15.5 An Introduction to Scheme 691 The NULL? function tests its parameter to determine whether it is the empty list and returns ...
692 Chapter 15 Functional Programming Languages (DEFINE (member atm a_list) (COND ((NULL? a_list) #F) ((EQ? atm (CAR a_list)) #T ...
15.5 An Introduction to Scheme 693 unequal atoms are found. When this occurs, the process need not continue, so the default case ...
694 Chapter 15 Functional Programming Languages The definition of append is^7 (DEFINE (append list1 list2) (COND ((NULL? list1) ...
15.5 An Introduction to Scheme 695 (DEFINE (quadratic_roots a b c) (LET ( (root_part_over_2a (/ (SQRT (− (* b b) (* 4 a c))) (* ...
696 Chapter 15 Functional Programming Languages example of this approach, consider the factorial function from Section 15.5.7, w ...
15.5 An Introduction to Scheme 697 15.5.13.1 Functional Composition Functional composition is the only primitive functional form ...
698 Chapter 15 Functional Programming Languages given function to each element of the given list and returns a list of the resul ...
15.6 Common LISP 699 ((NULL? a_list) 0) (ELSE (+ (CAR a_list) (adder (CDR a_list)))) )) Following is an example call to adder, a ...
«
31
32
33
34
35
36
37
38
39
40
»
Free download pdf