** TODO Some TODOs here [1/2]
- [X] do something
- [ ] and something else
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
def is_palindrome(s: str) -> bool: | |
def _is_palindrome(lst: list[str]) -> bool: | |
match lst: | |
case [x, *xs, y]: | |
return x == y and _is_palindrome(xs) | |
case _: | |
return True | |
return _is_palindrome(list(s)) |
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 collections | |
import random | |
def iter_words(rows): | |
return ( | |
s.strip() for row in rows for s in row.split(" ") if s.strip() != "" | |
) | |
- Never written a poem before
- Make the computer generate a poem for me
- Wikipedia:
A Markov chain is a stochastic model describing a sequence of possible events in which the probability of each event depends only on the state attained in the previous event.
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
const assert = require("assert"); | |
const Environment = require("./Environment"); | |
const GlobalEnvironment = new Environment({ | |
null: null, | |
true: true, | |
false: false, | |
VERSION: "0.1", |
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 set? | |
(lambda (lat) | |
(cond | |
[(null? lat) #t] | |
[(null? (cdr lat)) #t] | |
[(eq? (car lat) (car (cdr lat))) #f] | |
[else (and (set? (cons (car lat) (cdr (cdr lat)))) | |
(set? (cdr lat)))]))) |
- Syntax:
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 | |
(provide (all-defined-out)) | |
;; definition of structures for MUPL programs - Do NOT change | |
(struct var (string) #:transparent) ;; a variable, e.g., (var "foo") | |
(struct int (num) #:transparent) ;; a constant number, e.g., (int 17) | |
(struct add (e1 e2) #:transparent) ;; add two expressions | |
(struct ifgreater (e1 e2 e3 e4) #:transparent) ;; if e1 > e2 then e3 else e4 | |
(struct fun (nameopt formal body) #:transparent) ;; a recursive(?) 1-argument function |
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 | |
(provide (all-defined-out)) | |
;; 1 | |
(define (sequence low high stride) | |
(if (> low high) | |
null | |
(cons low (sequence (+ low stride) high stride)))) |
NewerOlder