Created
December 31, 2020 23:30
-
-
Save Gavinok/3aeb64f4e6d0c15fd5db3162c3b4e2da to your computer and use it in GitHub Desktop.
Introduction to the Racket programming language
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
#lang racket | |
"hello" | |
1 | |
2.3 | |
#t | |
#f | |
'(1 "hello" #t) | |
(define a 1) | |
a | |
(- 2 a) | |
(define (a arg) | |
(+ 1 arg)) | |
a | |
(define a | |
(lambda (arg) | |
(+ 1 arg))) | |
(a 1) | |
(map | |
(lambda | |
(item) | |
(+ item 1)) | |
'(1 2 3 4 5)) | |
(if (positive? -1) | |
;then | |
"yes this is true" | |
;else | |
"no this is false") | |
(define li '(1 2 3 4 5)) | |
(define (sum li) | |
(if (empty? li) | |
;then | |
0 | |
;else | |
(+ | |
;first element of list | |
(car li) | |
;sum rest of list | |
(sum (cdr li))))) | |
; 1 + (sum '(2 3 4 5)) | |
; 1 + 2 + (sum '( 3 4 5)) | |
; 1 + 2 + (sum '( 3 4 5)) | |
; 1 + 2 + 3 +(sum '( 4 5)) | |
; 1 + 2 + 3 + 4 + (sum '( 5)) | |
; 15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment