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
| (ns school) | |
| (defn grade [school grade-num] | |
| (get school grade-num [])) | |
| (defn add [school name grade-num] | |
| (assoc | |
| school | |
| grade-num | |
| (conj (grade school grade-num) name))) |
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
| (ns school) | |
| (defn grade [school grade-num] | |
| (get school grade-num [])) | |
| (defn add [school name grade-num] | |
| (assoc | |
| school | |
| grade-num | |
| (conj (grade school grade-num) name))) |
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
| (ns school) | |
| (defn grade [school grade-num] | |
| (get school grade-num [])) | |
| (defn add [school name grade-num] | |
| (assoc | |
| school | |
| grade-num | |
| (conj (grade school grade-num) name))) |
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
| (ns rpn.t-core | |
| (:use midje.sweet) | |
| (:use [rpn.core])) | |
| (facts | |
| "about RPN calculator" | |
| (fact | |
| "a number evaluates to itself" | |
| (evaluate "0") => 0 | |
| (evaluate "1") => 1) |
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
| (ns rpn.core | |
| [:use [clojure [string :only [split]]]]) | |
| (defn parse-int [s] | |
| (Integer/parseInt (re-find #"\A-?\d+" s))) | |
| (defn parse [expression] | |
| (let | |
| [operators {"+" + "-" - "*" * "/" quot} | |
| parse-token |
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
| (ns robot) | |
| (defn robot [] | |
| (atom {:name ""})) | |
| (defn robot-name [robot] | |
| (let | |
| [current-name (:name @robot) | |
| random-name | |
| (fn [] |
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 | |
| (define (grains) | |
| (letrec | |
| ([f | |
| (lambda (n) | |
| (cons n | |
| (lambda () (f (* 2 n)) )))]) | |
| (f 1))) |
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
| fun append(xs, ys) = | |
| case xs of | |
| [] => ys | |
| | head::tail => head::append(tail, ys) | |
| val testAppend1 = append([1, 2, 3, 4], [5, 6, 7]) | |
| (* val testAppend1 = [1,2,3,4,5,6,7] : int list *) | |
| val testAppend2 = append([], [5, 6, 7]) | |
| (* val testAppend2 = [5,6,7] : int list *) |
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 | |
| (require rackunit) | |
| (define (deep-list-map f dls) | |
| (if (null? dls) | |
| null | |
| (let [(first-dls (first dls))] | |
| (cons | |
| (if (list? first-dls) |
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 | |
| (require rackunit) | |
| (define (deep-list-accumulate comb base dls) | |
| (if (null? dls) | |
| base | |
| (let [(first-dls (first dls))] | |
| (comb (deep-list-accumulate comb base (rest dls)) | |
| (if (list? first-dls) |