1. Define functional form, simple list, bound variable, and referential transparency.
Answer : A higher-order function, or functional form, is one that either takes one or more functions as parameters or yields a function as its result, or both. A simple list is the problem of membership of a given atom in a given list that does not include sublists. A bound variable is a variable that never changes in the expression after being bound to an actual parameter value at the time evaluation of the lambda expression begins. A referential transparency is the execution of a function always produces the same result when given the same parameters
2. What does a lambda expression specify?
Answer : In Scheme, a nameless function actually includes the word LAMBDA, and is called a lambda expression. For example, (LAMBDA (x) (* x x)) is a nameless function that returns the square of its given numeric parameter. This function can be applied in the same way that named functions are: by placing it in the beginning of a list that contains the actual parameters.
7. What does the abbreviation REPL stand for?
Answer : REPL stand for read-evaluate-print loop
8. What are the three parameters to IF?
Answer : The Scheme two-way selector function, named IF, has three parameters: a predicate expression, a then expression, and an else expression. A call to IF has the form (IF predicate then_expression else_expression)
11. What are the two forms of DEFINE?
Answer : DEFINE takes two lists as parameters. The first parameter is the prototype of a function call, with the function name followed by the formal parameters, together in a list. The second list contains an expression to which the name is to be bound.
12. Describe the syntax and semantics of COND.
Answer : The syntax of COND is
. . .
The semantics of COND is as follows: The predicates of the parameters are evaluated one at a time, in order from the first, until one evaluates to #T. The expression that follows the first predicate that is found to be #T is then evaluated and its value is returned as the value of COND. If none of the predicates is true and there is an ELSE, its expression is evaluated and the value is returned. If none of the predicates is true and there is no ELSE, the value of COND is unspecified. Therefore, all CONDs should include an ELSE.
27. What is the use of the fn reserved word in ML?
Answer : The predicate function is often given as a lambda expression, which in ML is defined exactly like a function, except with the fn reserved word, instead of fun, and of course the lambda expression is nameless.
29. What is a curried function?
Answer : Curried functions are interesting and useful because new functions can be constructed from them by partial evaluation.
30. What does partial evaluation mean?
Answer : Partial evaluation means that the function is evaluated with actual parameters for one or more of the leftmost formal parameters.
31. Define reader macros.
Answer : Reader macros or read macros, that are expanded during the reader phase of aLISP language processor. A reader macro expands a specific character into a string of LISP code. For example, the apostrophe in LISP is a read macro that expands to a call to QUOTE. Users can define their own reader macros to create other shorthand constructs.
32.What is the use of evaluation environment table?
Answer : A table called the evaluation environment stores the names of all implicitly and explicitly declared identifiers in a program, along with their types. This is like a run-time symbol table. When an identifier is declared, either implicitly or explicitly, it is placed in the evaluation environment.
33. Explain the process of currying.
Answer : The process of currying replaces a function with more than one parameter with a function with one parameter that returns a function that takes the other parameters of the initial function.
43. What is the syntax of lambda expression in F#?
Answer : The syntax in F# is (fun a b −> a / b)
6. Refer to a book on Haskell programming and discuss the features of Haskell
Lazy evaluation or call-by-need is an evaluation strategy which delays the evaluation of an expression until its value is needed (non-strict evaluation) and which also avoids repeated evaluations (sharing). The sharing can reduce the running time of certain functions by an exponential factor over other non-strict evaluation strategies, such as call-by-name.
Pattern matching is the act of checking a perceived sequence of tokens for the presence of the constituents of some pattern. In contrast to pattern recognition, the match usually has to be exact. The patterns generally have the form of either sequences or tree structures. Uses of pattern matching include outputting the locations (if any) of a pattern within a token sequence, to output some component of the matched pattern, and to substitute the matching pattern with some other token sequence.
List comprehension is a syntactic construct available in some programming languages for creating a list based on existing lists. It follows the form of the mathematical set-builder notation (set comprehension) as distinct from the use of map and filter functions.
Type class is a type system construct that supports ad-hoc polymorphism. This is achieved by adding constraints to type variables in parametrically polymorphic types. Such a constraint typically involves a type class T and a type variable a, and means that a can only be instantiated to a type whose members support the overloaded operations associated with T.
Polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface.
7. What features make F# unique when compared to other languages?
F# has a full-featured IDE, an extensive library of utilities that supports imperative, object-oriented, and functional programming, and has interoperability with a collection of nonfunctional languages. F# includes a variety of data types. Among these are tuples, like those of Python and the functional languages ML and Haskell, lists, discriminated unions, an expansion of ML’s unions, and records, like those of ML, which are like tuples except the components are named. F# has both mutable and immutable arrays.
8.How is the functional operator pipeline(|>)used in F#?
The pipeline operator is a binary operator that sends the value of its left operand, which is an expression, to the last parameter of the function call, which is the right operand. It is used to chain together function calls while flowing the data being processed to each call. Consider the following example code, which uses the high-order functions filter and map:
let myNums = [1; 2; 3; 4; 5]
let evensTimesFive = myNums
|> List.filter (fun n −> n % 2 = 0)
|> List.map (fun n −> 5 * n)