Advertisement
M4T3US2

paradygmaty prog podst

Apr 6th, 2019
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.60 KB | None | 0 0
  1. #lang racket
  2. ;komentarz
  3. ;2 + 2
  4. (+ 2 2)
  5. ;2*(4+3)
  6. (* 2 (+ 4 3))
  7.  
  8. (define x 10)
  9. (if (> x 4)
  10.     "x jest wieksze od 4"
  11.     "x jest mniejszy lub rowny 4")
  12.  
  13. (if (= x 0)
  14.     (/ 10 x)
  15.     (* x 2))
  16. ;odpowiednik c++ case
  17. (cond
  18.   ((= x 0) "x jest rowne 0")
  19.   ((> x 0) "x jest wieksze od 0")
  20.   (else "x jest mniejsze od 0"))
  21.  
  22. (define (kw x) (* x x))
  23. (kw 10)
  24.  
  25. ;zmienne lokalne
  26. (let ((a 10) (b 10))
  27.   (* a b 2))
  28.  
  29. ;zagniezdzanie
  30. (let ((a 10))
  31.   (let ((b 12))
  32.     (+ a b)))
  33.  
  34. ;definicja listy
  35. (define lst '(1 2 3 4))
  36. lst
  37. (car lst)
  38. (cdr lst)
  39. (cons 1'(1 2 3 4))
  40. (list 1 '(1 2 3 4))
  41. (cons 1 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement