Thursday, June 29, 2023

racket basic

 #lang racket


; define a constant

(define myval 3.14)


; function without param

(define myfunc

  (λ ()

    (+ 3 4)))


; call function

(myfunc)


; function with param(which is one formal)

(define myfunc-mul-two

  (λ (x)

    (* 2 x)))


(myfunc-mul-two 4)


; outer function calls inner function

(define double-result-of-f

  (λ (f)

    (λ (z)

      (* 2 (f z)))))


(define add3

  (λ (x)

    (+ 3 x)))


((double-result-of-f add3) 4)


No comments:

Post a Comment

Task in UnrealEngine

 https://www.youtube.com/watch?v=1lBadANnJaw