# ФУНКЦИИ БОЛЕЕ ВЫСОКОГО ПОРЯДКА

• Published on
19-Mar-2016

• View
47

1

Embed Size (px)

DESCRIPTION

. .. . - PowerPoint PPT Presentation

Transcript

• ..

• , , , . , .. , .

• , , . , , , , - .

• , , , . , , .. , , -, , .

• , , , , . . :

_(car '(lambda (x) (list x))) LAMBDA_((lambda (x) (list x)) 'car) (CAR)

• CAR - , CAR . -, , , CAR . : , .

• , : . . .

• , (1), (2) . , ( , ), -, ( ).

• , , . :... '(lambda (x) (list x)) ...... (list 'lambda '(x) (list list 'x)) ...... (first '(car cdr cons)) .

• , , . . . , , , , . .

• : ; ( , ).

• , , DEFUN . (FUNCALL, APPLY), . , . , (SYMBOL-VALUE).

• :1. :(defun f ...( g))2. :(defun f ...( g))3. : (defun f ...(f(f)))4. : (defun f (... g ...)(apply g ))

• , , , , . , , :5. : (defunf(...f...)... (apply f... f ...)...)

• . , , . . . , .

• ( 4 5) (1, 2, 3), , , . , , .

• , . . . , .. .

• , , , . .

• EVAL. EVAL (), . VAL APPLY , a APPLY EVAL .

• . APPLY FUNCALL, , .

• APPLY APPLY , , , APPLY:(APPLY fn ) (fn 'xl 'x2 ... 'xN), =(1 x2 ... xN)

• _(apply '+ '(2 3))5_(apply 'cons '() ())( )_(setq f +)+_(apply f '(2 3))5 _( apply 'apply '(+ 2 3)))5_(apply (lambda (x y) (+ x )) '(2 3))5

• FUNCALL FUNCALL APPLY, , :(FUNCALL fnxt x2 ... xN) (fn x1 x2 ... xN) :_(funcall '+2 3)5

• _(setq '+)+_(funcall 2 3)5_(funcall (car '(+ - * /)) 2 3)5

• . , , ( -), ( ) :_(setq cons '+)_(funcall cons 2 3) 5 _(cons 2 3) (2 . 3)

• FUNCALL , , . "" . , QUOTE SETQ, , .

• 1. :(apply list '( b))(funcall list '( b))(funcall 'apply list '( b))(funcall list 'apply '(a b))(funcall 'funcall 'funcall list list '(a b))2. FUNCALL APPLY.