This file contains hidden or 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 | |
;; this file uses the back-end | |
(require "back-end.rkt") | |
;; read lines from an input file | |
(define lines (file->lines "/tmp/input.src")) | |
(serialize (reverse lines)) |
This file contains hidden or 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 | |
;; this file implements the awesome back end of the compiler | |
(provide serialize) | |
;; given an intermediate representation, serialize it to a file | |
(define (serialize ir) | |
(call-with-output-file "/tmp/zz.txt" |
This file contains hidden or 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 | |
(require typed/rackunit) | |
;; given a number, return the fizzbuzz game string | |
(define (fizzbuzz-num [n : Natural]) : String | |
(cond [(= 0 (modulo n 15)) "fizzbuzz"] | |
[(= 0 (modulo n 3)) "fizz"] | |
[(= 0 (modulo n 5)) "buzz"] | |
[else (number->string n)])) |
This file contains hidden or 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 | |
(require typed/rackunit) | |
(define-type Value String) | |
(define-type ExprC (U ConcatC StrC)) | |
(struct ConcatC ([l : ExprC] [r : ExprC]) | |
#:transparent) |
This file contains hidden or 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 | |
(require typed/rackunit) | |
(define-type Value String) | |
(define-type ExprC (U ConcatC StrC)) | |
(struct ConcatC ([l : ExprC] [r : ExprC]) | |
#:transparent) |
This file contains hidden or 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 | |
;; purpose statement goes here... | |
(define (fun-for-lists [l : (Listof Any)]) ; refine the types... | |
(match l | |
['() ...] | |
[(cons fst rst) ... fst ... (fun-for-lists rst) ...])) |
This file contains hidden or 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 | |
(require typed/rackunit) | |
(: my-list (Listof Number)) | |
(define my-list | |
(cons 6 (cons 12 (cons 13+4i (cons 16 '()))))) |
This file contains hidden or 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 | |
(define my-list | |
(cons 3 | |
(cons 4 (cons "horse" (cons (cons 16 '()) | |
'()))))) | |
;; determine the length of a list | |
(define (mylen [l : (Listof Any)]) : Natural | |
(match l |
This file contains hidden or 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
You will not, and will not permit anyone else to: (1) modify, adapt, alter, | |
translate or create derivative works of this Application; (2) use or merge | |
this Application, or any component or element of this Application, with | |
other software, databases or services not provided by us; (3) sublicense, | |
distribute, sell or otherwise transfer the Application to any other party; | |
(4) use the Application as a service bureau, or lease, rent or loan this | |
Application to any third party; (5) reverse engineer, decompile, disassemble | |
or otherwise attempt to derive the source code or structure of this | |
Application; (6) interfere in any manner with the operation of this | |
Application; (7) circumvent, or attempt to circumvent, any electronic |
This file contains hidden or 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
running example: | |
(((λ (f) (λ (y) (f y 9))) (λ (a b) (+ a b))) 3) | |
oh, let's write it in consieuten: | |
fun makeCaller ((int int -> int) f) (int -> int) { | |
fun caller(int y) int { | |
return f(y,9); | |
} |