Warning, /frameworks/syntax-highlighting/autotests/folding/test.rkt.fold is written in an unsupported language. File is not indexed.

0001 #lang racket/gui
0002 
0003 (define my-language 'English)
0004 
0005 (define translations
0006   #hash([English . "Hello world"]
0007         [French . "Bonjour le monde"]
0008         [German . "Hallo Welt"]
0009         [Greek . "Γειά σου, κόσμε"]
0010         [Portuguese . "Olá mundo"]
0011         [Spanish . "Hola mundo"]
0012         [Thai . "สวัสดีชาวโลก"]))
0013 
0014 (define my-hello-world
0015   (hash-ref translations my-language
0016             "hello world"))
0017 
0018 (message-box "" my-hello-world)
0019 
0020 ; Organizing interconnected function definitions with local
0021 ; [List-of Number] [Number Number -> Boolean]
0022 ; -> [List-of Number]
0023 ; produces a version of alon0, sorted according to cmp
0024 (define (sort-cmp alon0 cmp)
0025   (local (; [List-of Number] -> [List-of Number]
0026           ; produces the sorted version of alon
0027           (define (isort alon)
0028             (cond
0029               [(empty? alon) '()]
0030               [else
0031                (insert (first alon) (isort (rest alon)))]))
0032 
0033           ; Number [List-of Number] -> [List-of Number]
0034           ; inserts n into the sorted list of numbers alon
0035           (define (insert n alon)
0036             (cond
0037               [(empty? alon) (cons n '())]
0038               [else (if (cmp n (first alon))
0039                         (cons n alon)
0040                         (cons (first alon)
0041                               (insert n (rest alon))))])))
0042     (isort alon0)))
0043