Thank you for your comment

Beau­tiful Racket / racket school 2019

  1. 42+3i 1/3 0.333
    #b101010 #x2a #o52
    "hello world"
    #\h
    #true
    #t
    #false ; yes, we have no falsiness
    #f
    'sym
    (void)
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    42+3i 1/3 0.333
    #b101010 #x2a #o52
    "hello world"
    #\h
    #true
    #t
    #false ; yes, we have no falsiness
    #f
    'sym
    (void)
    
    copy to clipboard
  2. (list 1 2 3)
    '[4 5 6]
    `{2 3 ,(+ 4 5)}
    `{,(list 7 8 9)}
    `{,@(list a b c)}
    '(d . (e . (f)))
    (cons 'x (cons 'y (cons 'z null)))
    1
    2
    3
    4
    5
    6
    7
    (list 1 2 3)
    '[4 5 6]
    `{2 3 ,(+ 4 5)}
    `{,(list 7 8 9)}
    `{,@(list a b c)}
    '(d . (e . (f)))
    (cons 'x (cons 'y (cons 'z null)))
    
    copy to clipboard
  3. (lambda (x) (abs x))
    (λ (x) (abs x))
    ((λ (x) (abs x)) -42)
    (abs -42)
    (apply (λ (x) (abs x)) (list -42))
    (apply abs (list -42))
    (map abs '(-1 2 3 -4))
    (filter abs '(-1 2 3 -4))
    (filter even? (map abs '(-1 2 3 -4)))
    (6 . * . 7)
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    (lambda (x) (abs x))
    (λ (x) (abs x))
    ((λ (x) (abs x)) -42)
    (abs -42)
    (apply (λ (x) (abs x)) (list -42))
    (apply abs (list -42))
    (map abs '(-1 2 3 -4))
    (filter abs '(-1 2 3 -4))
    (filter even? (map abs '(-1 2 3 -4)))
    (6 . * . 7)
    
    copy to clipboard
  4. (define val 42)
    (define (f x) (+ x x))
    (define g (λ (x) (+ x x)))
    (let ([f (λ (x) (* x x))]
          [res (f val)])
      res)
    (let* ([f (λ (x) (* x x))]
           [res (f val)])
      res)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    (define val 42)
    (define (f x) (+ x x))
    (define g (λ (x) (+ x x)))
    (let ([f (λ (x) (* x x))]
          [res (f val)])
      res)
    (let* ([f (λ (x) (* x x))]
           [res (f val)])
      res)
    
    copy to clipboard
  5. (if (even? 42) #true #false)
    (when (even? 42) #true)
    (unless (even? 42) 'destroy-galaxy)
    (cond
      [(even? 42) #true]
      [else #false])
    (let ([val 42])
      (case val
        [(42) #true]
        [else #false]))
    (match 42
      [(? even?) #true]
      [_ #false])
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    (if (even? 42) #true #false)
    (when (even? 42) #true)
    (unless (even? 42) 'destroy-galaxy)
    (cond
      [(even? 42) #true]
      [else #false])
    (let ([val 42])
      (case val
        [(42) #true]
        [else #false]))
    (match 42
      [(? even?) #true]
      [_ #false])
    
    copy to clipboard
  6. (for/list ([i (in-range 1 5)]
               [j (in-naturals 6)])
      (list i j))

    (for/fold ([sum 0])
              ([i (in-range 1 5)]
               [j (in-naturals 6)])
      (+ sum i j))

    (for/sum ([i (in-range 1 5)]
              [j (in-naturals 6)])
      (+ i j))

    (apply +
           (apply append
                  (for/list ([i (in-range 1 5)]
                             [j (in-naturals 6)])
                    (list i j))))
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    (for/list ([i (in-range 1 5)]
               [j (in-naturals 6)])
      (list i j))
    
    (for/fold ([sum 0])
              ([i (in-range 1 5)]
               [j (in-naturals 6)])
      (+ sum i j))
    
    (for/sum ([i (in-range 1 5)]
              [j (in-naturals 6)])
      (+ i j))
    
    (apply +
           (apply append
                  (for/list ([i (in-range 1 5)]
                             [j (in-naturals 6)])
                    (list i j))))
    
    copy to clipboard
  7. (module inner br
      (provide foo (rename-out [barbara bar]))
      (define foo 'inner-foo)
      (define barbara 'inner-bar))
    (require 'inner)
    (define foo 'outer-foo)
    foo
    bar
    1
    2
    3
    4
    5
    6
    7
    8
    (module inner br
      (provide foo (rename-out [barbara bar]))
      (define foo 'inner-foo)
      (define barbara 'inner-bar))
    (require 'inner)
    (define foo 'outer-foo)
    foo
    bar
    
    copy to clipboard
  8. (define-macro (dbl ARG)
      #'(list ARG ARG))

    (define-macro-cases foo
      [(_ 42) #'"kaboom!"]
      [(_ ARG) #'(list ARG ARG)])

    (define-macro (rev ARG0 "foo" ARG ...)
      #'(append (reverse (list 'ARG ...)) (list 'ARG0)))

    (define-macro (tell ARG ...)
      #'(for ([name (in-list (list 'ARG ...))])
          (displayln (format "~a = ~a" name ARG)) ...))
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    (define-macro (dbl ARG)
      #'(list ARG ARG))
    
    (define-macro-cases foo
      [(_ 42) #'"kaboom!"]
      [(_ ARG) #'(list ARG ARG)])
    
    (define-macro (rev ARG0 "foo" ARG ...)
      #'(append (reverse (list 'ARG ...)) (list 'ARG0)))
    
    (define-macro (tell ARG ...)
      #'(for ([name (in-list (list 'ARG ...))])
          (displayln (format "~a = ~a" name ARG)) ...))
    
    copy to clipboard
← prev next →