Added Typed Racket.

WTF this language actually sucks.
This commit is contained in:
2025-10-07 19:49:43 -04:00
parent 34cee3e910
commit 93e78f6066
8 changed files with 248 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname main) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
; foo: (bar: A → A) → (A → A)
(define (foo bar)
(local [(define (baz buzz)
(bar (bar buzz)))] baz))
(check-expect ((foo add1) 1) 3)
; goodies: (good?: A → Boolean, l: [A]) → [Index]
; Returns a list of indices considered "good."
(define (goodies good? l)
(local [; goodies/help: (good?: A → Boolean, l :[A], i: Int, a: [Index]) → [Index]
(define (goodies/help l i a)
(cond [(empty? l) (reverse a)]
[(good? (first l)) (goodies/help (rest l) (add1 i) (cons i a))]
[else (goodies/help (rest l) (add1 i) a)]))]
(goodies/help l 0 '())))
(check-expect (goodies even? '(1 2 3 4 5)) '(1 3))
(check-expect (goodies even? '()) '())