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
import random | |
# Roll an n-sided die | |
def d(n): | |
return random.randint(1, n) | |
# Roll an n-sided die, exploding on maximum value | |
def e(n): | |
total = 0 | |
while True: |
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 | |
; Empty list | |
(define empty (λ (l) (l 'error 'error #t))) | |
(define empty? (λ (l) (l (λ (a d e) e)))) | |
; Build and take apart lists | |
(define pair (λ (a d) (λ (l) (l a d #f)))) | |
(define first (λ (l) (l (λ (a d e) a)))) | |
(define rest (λ (l) (l (λ (a d e) d)))) |