You are on page 1of 3

Контрольні завдання за лекцією з “Мультипарадигменного програмування”

студента групи ІТ-04


Гавриленка Яна Сергійовича

Код

;main.rkt
#lang racket
 
; я комментарий
(displayln "Hello world!")

(displayln "winter is comming!")

(displayln (- 128 37))

(displayln (- 10 100 12 18))

(displayln (- 100 34 22 (+ 5 (- 3 10))))

(displayln (+ 4 (
                  - 2 (* 3 5) (/ 8 7)
                  )))

(define place-count 0)
(set! place-count 100)
(displayln place-count)

(define cube (lambda (n) (* n n n)))

(cube 3)

(define result ((lambda (x y) (/ (+ x y) 2))


                2 4))
(displayln result)

(define (sum-of-squares a b) (+ (* a a) (* b b)))


(displayln (sum-of-squares 2 3))

(require "mod.rkt")
(displayln PI)

(define (square-of-sum x y)
  (let ([sum (+ x y)])
    (displayln (* sum sum))))
(square-of-sum 2 3)

(define (even? n) (= (remainder n 2) 0))

(define (same-parity? a b)
  (not (xor(even? a) (even? b))))

(same-parity? 3 9)

(define (sentence-type x)
  (
   if (equal? (string-upcase x) x)
                               "cry"
                               "common"))
(sentence-type "some a")

(define (sayboom n)
  (when (equal? n "go")
 (display "Boom!"))
  )

(sayboom "go")
(sayboom "Go")

(define (humanize-permission v)
 (case v
    [("x") "execute"]
    [("w") "write"]
    [("r") "read"])
  )
КОД модулю mod.rkt
;mod.rkt
#lang racket
(provide PI)
(define PI 3.14)

Виконання програми

You might also like