-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use (define) syntax sugar in examples
- Loading branch information
Showing
6 changed files
with
21 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
(define foldr (lambda (op init lst) | ||
(define (foldr op init lst) | ||
(if (null? lst) | ||
init | ||
(op (car lst) (foldr op init (cdr lst)))))) | ||
(op (car lst) (foldr op init (cdr lst))))) | ||
|
||
(define sum (lambda (lst) | ||
(foldr + 0 lst))) | ||
(define (sum lst) | ||
(foldr + 0 lst)) | ||
|
||
(display (sum (list 1 2 3))) | ||
(newline) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
(define map (lambda (fn lst) | ||
(define (map fn lst) | ||
(if (null? lst) | ||
lst | ||
(cons (fn (car lst)) (map fn (cdr lst)))))) | ||
(cons (fn (car lst)) (map fn (cdr lst))))) | ||
|
||
(define double (lambda (x) (* 2 x))) | ||
|
||
(display (map double (list 1 2 3))) | ||
(display (map (lambda (x) (* 2 x)) (list 1 2 3))) | ||
(newline) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
(define not (lambda (x) | ||
(if (equal? #t x) #f #t))) | ||
(define (not x) | ||
(if (equal? #t x) #f #t)) | ||
|
||
(define PI 3.41) | ||
|
||
|
This file contains 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