This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;The following pattern of numbers is called Pascal's triangle | |
| (defun pascal_x_y (x y) | |
| (if (or (= y 0) (= x y)) | |
| 1 | |
| (+ (pascal_x_y (- x 1) (- y 1)) | |
| (pascal_x_y (- x 1) y)))) | |
| (defun draw_line (n) | |
| (loop for idx from 0 to n do | |
| (prin1 (pascal_x_y n idx)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;A function f is defined by the rule that f(n) = n if n<3 and | |
| ; f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) if n> 3. | |
| ; Write a procedure that computes f by means of a recursive process. | |
| ; Write a procedure that computes f by means of an iterative process. | |
| (defun func_f (n) | |
| (if (< n 4) n | |
| (+ (func_f (- n 1)) | |
| (* 2 (func_f (- n 2))) | |
| (* 3 (func_f (- n 3)))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if request.method == 'POST': | |
| fields = request.GET['_proxy_fields'].split(',') | |
| params = {} | |
| for field in fields: | |
| if len(field) == 0: continue | |
| params[field] = request.POST[params] | |
| if request.method == 'POST': | |
| data = urllib.urlencode(params) | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. | |
| (define (sum_squares_top2 c1 c2 c3) | |
| (+ | |
| (square max(c1 c2)) | |
| (square max((min c1 c2) c3)))) |
NewerOlder