Skip to main content Svelte Highlight v7.21.1

Racket language preview

1. A contracted function

#lang line, define/contract, and a format string
horizon-dark
#lang racket
;; sum of two numbers with a contract
(define/contract (add a b)
  (-> integer? integer? integer?)
  (+ a b))

(define pi 3.14159)
(displayln (format "~a" (add 1 2)))
atom-one-dark
#lang racket
;; sum of two numbers with a contract
(define/contract (add a b)
  (-> integer? integer? integer?)
  (+ a b))

(define pi 3.14159)
(displayln (format "~a" (add 1 2)))
github-dark
#lang racket
;; sum of two numbers with a contract
(define/contract (add a b)
  (-> integer? integer? integer?)
  (+ a b))

(define pi 3.14159)
(displayln (format "~a" (add 1 2)))
dracula
#lang racket
;; sum of two numbers with a contract
(define/contract (add a b)
  (-> integer? integer? integer?)
  (+ a b))

(define pi 3.14159)
(displayln (format "~a" (add 1 2)))
nord
#lang racket
;; sum of two numbers with a contract
(define/contract (add a b)
  (-> integer? integer? integer?)
  (+ a b))

(define pi 3.14159)
(displayln (format "~a" (add 1 2)))
github
#lang racket
;; sum of two numbers with a contract
(define/contract (add a b)
  (-> integer? integer? integer?)
  (+ a b))

(define pi 3.14159)
(displayln (format "~a" (add 1 2)))

2. Structs and pattern matching

struct, match, and square-bracket binding forms
horizon-dark
(struct point (x y) #:transparent)

(define (describe p)
  (match p
    [(point 0 0) "origin"]
    [(point x y) (format "(~a, ~a)" x y)]))

(for/list ([p (list (point 0 0) (point 1 2))])
  (describe p))
atom-one-dark
(struct point (x y) #:transparent)

(define (describe p)
  (match p
    [(point 0 0) "origin"]
    [(point x y) (format "(~a, ~a)" x y)]))

(for/list ([p (list (point 0 0) (point 1 2))])
  (describe p))
github-dark
(struct point (x y) #:transparent)

(define (describe p)
  (match p
    [(point 0 0) "origin"]
    [(point x y) (format "(~a, ~a)" x y)]))

(for/list ([p (list (point 0 0) (point 1 2))])
  (describe p))
dracula
(struct point (x y) #:transparent)

(define (describe p)
  (match p
    [(point 0 0) "origin"]
    [(point x y) (format "(~a, ~a)" x y)]))

(for/list ([p (list (point 0 0) (point 1 2))])
  (describe p))
nord
(struct point (x y) #:transparent)

(define (describe p)
  (match p
    [(point 0 0) "origin"]
    [(point x y) (format "(~a, ~a)" x y)]))

(for/list ([p (list (point 0 0) (point 1 2))])
  (describe p))
github
(struct point (x y) #:transparent)

(define (describe p)
  (match p
    [(point 0 0) "origin"]
    [(point x y) (format "(~a, ~a)" x y)]))

(for/list ([p (list (point 0 0) (point 1 2))])
  (describe p))

3. Nested block comments

a comment wrapping an example that has its own comment
horizon-dark
#| adds two numbers
   #| example: (add 1 2) => 3 |#
|#
(define (add a b)
  (+ a b))
atom-one-dark
#| adds two numbers
   #| example: (add 1 2) => 3 |#
|#
(define (add a b)
  (+ a b))
github-dark
#| adds two numbers
   #| example: (add 1 2) => 3 |#
|#
(define (add a b)
  (+ a b))
dracula
#| adds two numbers
   #| example: (add 1 2) => 3 |#
|#
(define (add a b)
  (+ a b))
nord
#| adds two numbers
   #| example: (add 1 2) => 3 |#
|#
(define (add a b)
  (+ a b))
github
#| adds two numbers
   #| example: (add 1 2) => 3 |#
|#
(define (add a b)
  (+ a b))