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 db) | |
(require racket/date) | |
(define (connect file) | |
(sqlite3-connect #:database "/Users/sdatta/code/tasks.sqlite3")) | |
(define (add-task! conn |
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
program Genes; | |
uses crt, SysUtils; | |
const | |
CODONS = 'abcdefghijklmnopqr stuvwxyz0123456789'; | |
TARGET = 'happy new year 2024'; | |
PopulationSize = 1000; | |
type | |
StringArray = array[1..PopulationSize] of 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
#lang racket | |
(define (nest-list f exp n) | |
(do ([i 0 (+ i 1)] | |
[x exp (f x)] | |
[a '() (cons x a)]) | |
((>= i n) a))) | |
(define (nest-while f exp cnd) |
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
(defun nest-list (f exp n) | |
(do ((i n (- i 1)) | |
(n exp (funcall f n)) | |
(x nil (cons n x))) | |
((< i 0) x))) | |
(defun nest-while (f1 exp f2) | |
(do ((x exp (funcall f1 x)) | |
(a nil (cons x a))) | |
((not (funcall f2 x)) a))) |
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 codons (conj (map char (range (int \A) (inc (int \Z)))) \space)) | |
(defn rand-char [] | |
(rand-nth codons)) | |
(defn rand-str [len] | |
(apply str (map (fn [_] (rand-char)) | |
(range len)))) | |
(defn in-range? [n 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 racket | |
(require plot) | |
(define (sigmoid x) | |
(/ 1.0 (+ 1 (exp (- x))))) | |
(define (step x) | |
(if (>= x 0) 1 0)) |
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
open System | |
let hello (name: string) : string = "Hello " + name | |
let dotProduct (xs: double array) (ys: double array) : double = | |
Array.zip xs ys |> Array.map (fun (x, y) -> x * y) |> Array.sum | |
let activate (w: double) : double = if w >= 0.0 then 1.0 else 0.0 | |
let predict (ws: double array) (inputs: double array) : double = dotProduct ws inputs |> activate |
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
(defclass seq () ()) | |
(defmethod s-first ((s seq)) | |
"The first element, if exists" | |
(error "Implement in child class")) | |
(defmethod s-rest ((s seq)) | |
"The rest of the sequence, if exists" | |
(error "Implement in child class")) |
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
class Monkey | |
attr_accessor :items, :inspect_count | |
def initialize(game, name, items, expr, test, tmonkey, fmonkey) | |
@name = name | |
@items = items | |
@expr = expr | |
@test = test | |
@tmonkey = tmonkey | |
@fmonkey = fmonkey |
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
Deltas ← {¯1×(-/)¨2,/0,⍵} | |
Sells ← 2 4 8 10 12 24 25 | |
Buy ← 26 | |
Deltas Buy⌊+\ Sells |
NewerOlder