Students will provide only one copy of their solutions What

Students will provide only one copy of their solutions. What is a high order function in Lisp? Consider example below: Is plus1 a high order function? Why? Consider example below: Is map car a high order function? Why? (defund plus1 (x) (+ x 1)) (map car \'plus1 \'(1 2 3 4 5)) (2 3 4 5 6)

Solution

(a) High Order Function in Lisp: High order function can be defined as in which it takes the functions which are arguments or gives the result as function itself. And these functions can be used and explained in Lisp System. We have a Map function in Lisp and it is named as MAPCAR.

Suppose let us consider in a company we want to increase the salary of a person for $200

For Example ((X . 20000) (Y . 30000))

b.

YES,defun plus1(x)(+x 1) in plus1 is higher order function in LISP

DEFUN doing two things :

FUNCTION operator provides mechanism for getting at a function object.it takes single argument and returns the function with that name.

For example if you consider like (defun multi (x) (* 2 x))

Here multiplication is done

defun plus1(x)(+x 1) in this addition is done every time +1 added to x i.e every time raising of one is done so it is higher function

(c)

map car is function in which it calls the first argument with each element having in its second argument. second argument is should be a sequence.

Map car means mapping over a domain.

For example

From the above example it is clearly shown that

=>(2 3 4 5 6) in which it increases the element by one time. Thus it is a High order function. Yes mapcar is a high order function

 Students will provide only one copy of their solutions. What is a high order function in Lisp? Consider example below: Is plus1 a high order function? Why? Con

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site