Skip to content

Instantly share code, notes, and snippets.

//pseudo code beloew
array = 1 2 3 4 1 2 3 4 5 1 2 3
//should print at the end 1 2 3 4 5 with count 5
max = 1
maxstart = 0
maxend = 0
(ns student.learning
(:refer-clojure :exclude [get])
(:use [clojure.contrib.str-utils :only [str-join]]
[clojure.contrib.math :only [sqrt lcm]]
[clojure.contrib.lazy-seqs :only [primes]]))
(defn babyize [s] "replace l and r with w if first letter of each word"
(let [b-word (fn [[first-letter & word]]
(let [new-first (cond (some #{first-letter} [\l \r]) \w
(some #{first-letter} [\L \R]) \W
(ns student.learning
(:refer-clojure :exclude [get])
(:use [clojure.contrib.str-utils :only [str-join]]
[clojure.contrib.math :only [sqrt lcm]]
[clojure.contrib.lazy-seqs :only [primes]]))
(defn babyize [s] "replace l and r with w if first letter of each word"
(let [b-word (fn [[first-letter & word]]
(let [new-first (cond (some #{first-letter} [\l \r]) \w
(some #{first-letter} [\L \R]) \W
(ns attendance.core
(:use karras.core
karras.collection
karras.sugar
compojure.core
ring.adapter.jetty
hiccup.core)
(:require [compojure.route :as route]))
(defn home []
;;restart swank
(fset 'restart-swank
"\C-[xslime-disconna\C-?ect-all\C-m\C-[xswank-clojure-project\C-m\C-m")
(global-set-key "\C-cS" 'restart-swank)
(do
(use 'clojure.test)
(defn re-test [ns]
(remove-ns ns)
(require :reload-all ns)
(run-tests ns)))
;; pick a namespace
(re-test 'clojure.test-clojure.other-functions)
;;problem 14
(defn do-to-odd [x]
(+ 1 (* 3 x)))
(defn do-to-even [x]
(/ x 2))
(defn get-next [x]
(defn pow [x y]
(apply * (repeat y x)))
;;problem 18
(def triangle18-str "75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
(defn test-copy [str-from str-to]
(let [from (file str-from)
to (file str-to)
in (java.io.FileReader. from)
out (java.io.FileWriter. to)]
(copy in out)))