This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
;;; problem-board and solved-board are included as examples | |
;;; (solve problem-board) should produce the same result as solved-board | |
(require rackunit) | |
;; A board is a 9-vector of 9-vectors (rows) of board-cells | |
(define (board? xs) | |
(define (row? r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang scribble/manual | |
This is a 3-argument curried function. | |
@defproc[(((lerp [lo number?]) | |
[hi number?]) | |
[alpha number?]) | |
number?]{ | |
Linear interpolation} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang typed/racket | |
;;; Typed Racket version of Martin Grabmü̈ller's "Algorithm W Step by Step" | |
;;; http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.65.7733 | |
;;; This is my first use of Typed Racket. I am looking to change this from | |
;;; following Haskell idiom to following Racket idiom. | |
;; An expression is a variable, a literal, an application, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require redex) | |
(define-language L1 | |
(a integer) | |
(e variable-not-otherwise-mentioned | |
(* e e))) | |
(define-language L2 | |
(b string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-language L1 | |
(a integer) | |
(e variable-not-otherwise-mentioned)) | |
(define-language L2 | |
(b string) | |
(e integer)) | |
(define-multilang-metafunction [L1 L2] | |
metafun-name : a L1:e -> b L2:e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; typing compose makes use of typechecker code for handling abstracted indices | |
(check-equal? | |
(judgment-holds | |
(type-of [] [] [] | |
(I-λ [(s1 Shape) (s2 Shape) (s3 Shape)] | |
(T-λ [α β γ] | |
(A [] [(λ [(f (Array (S) ((Array s1 α) -> (Array s2 β)))) | |
(g (Array (S) ((Array s2 β) -> (Array s3 γ))))] | |
(A [] [(λ [(x (Array s1 α))] (g (f x)))]))]))) | |
type) type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> (judgment-holds | |
(type-of [] | |
[] | |
[] | |
(Λ [α β γ] | |
(A [] | |
[(λ [(f 0 (Array (S) ((Array (S) α) -> (Array (S) β)))) | |
(g 0 (Array (S) ((Array (S) β) -> (Array (S) γ))))] | |
(A [] [(λ [(x 0 (Array (S) α))] (g (f x)))]))])) | |
type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require redex) | |
(define-language LBase | |
(e (+ e e) | |
number)) | |
(define-extended-language L1 LBase | |
(e .... | |
(- e e))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> (:print-type andmap) | |
(All (a c d b ...) | |
(case-> | |
(-> (-> a c : d) (Listof a) c) | |
(-> (-> a b ... b c) (Listof a) (Listof b) ... b (U True c)))) | |
> (λ ([a : Real] | |
[b : Symbol] | |
[c : Boolean] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(define (up-down x [so-far 1]) | |
(if (equal? x so-far) | |
(displayln x) | |
(begin (displayln so-far) | |
(up-down x (add1 so-far)) | |
(displayln so-far)))) |
NewerOlder