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 baseConv.core | |
(:require [clojure.string :as str]) | |
(:gen-class) | |
) | |
(def digitChars "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") | |
(defn powerOf [base] | |
"Returns a function which takes a number and raises the given base to that number. | |
The returned function returns its result as a Long unless the result exceeds |
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
;; P01 | |
(last [1 1 2 3 5 8]) | |
;; P02 | |
(defn penultimate [x] | |
(last (butlast x)) ) | |
;; P03 | |
(nth [1 1 2 3 5 8] 2) |
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
;; the missing drop-nth, versions of which, similar to this, have been floating around the Clojure forum: | |
;; | |
(defn drop-nth [n coll] | |
(lazy-seq | |
(when-let [xs (seq coll)] | |
(concat (take (dec n) xs) (drop-nth n (drop n xs))) | |
) | |
) | |
) |