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
datatype fruit = | |
Peach | |
| Apple | |
| Pear | |
| Lemon | |
| Fig | |
datatype tree = | |
Bud | |
| Flat of fruit * tree |
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
// sums, constructing | |
const tag = t => (...args) => ({ tag: t, values: [...args] }); | |
// testing | |
tag("label")(1, "horse", [2,3]); | |
// fruit | |
const Peach = tag("Peach")(); | |
const Apple = tag("Apple")(); | |
const Pear = tag("Pear")(); |
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
type KuEgenskaper = | |
{ navn : string | |
hoyde : int | |
} | |
type Animal = | |
| Coo of KuEgenskaper | |
| Hest of int | |
| Bamse |
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 alphabet (list->vector (string->list "abcdefghijklmnopqrstuvwxyzæøå "))) | |
(define (caeschar shift char) | |
(match char | |
[#\newline #\newline] | |
[#\return #\return] | |
[c (match (vector-member c alphabet) | |
[#f #f] |
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
// to run: jshell caesar.jsh | |
import java.util.concurrent.ScheduledExecutorService; | |
import java.util.concurrent.ScheduledThreadPoolExecutor; | |
import java.util.concurrent.TimeUnit; | |
import java.io.PrintStream; | |
public class Caechar { | |
public static Caechar fromAlphabet(String str) { |
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 lazy | |
; put racket instead of lazy in the line above to make it less lazy | |
(struct zero () #:transparent) | |
(struct succ (pred) #:transparent) | |
(define one (succ (zero))) | |
(define two (succ one)) | |
(define (inf) (succ (inf))) |
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
White tigers live mostly in India | |
Wild lions live mostly in Africa |
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 start '(0 3 3 3 0 1)) | |
(define a '(3 2 1 1 0 0)) | |
(define b '(0 0 1 0 1 0)) | |
(define c '(-1 1 -2 1 -2 1)) | |
(define d '(1 1 1 0 3 1)) | |
(define e '(-2 +2 0 -2 +2 -2)) |
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
local Cons = { | |
__tostring = function(cons) return "(" .. tostring(cons.car) .. " . " .. tostring(cons.cdr) .. ")" end | |
} | |
local function cons(car, cdr) | |
local res = { car = car, cdr = cdr } | |
setmetatable(res, Cons) | |
return res | |
end |
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
local function point(x, y) | |
return { x = x, y = y, key = x .. "," .. y } | |
end | |
local function points(lend) | |
local i = lend.idx | |
local off = 0 - lend.off | |
local other = lend.other.idx | |
local ended = false | |
local line = lend.line |