Skip to content

Instantly share code, notes, and snippets.

View manisnesan's full-sized avatar
🎯
Focusing

Manikandan Sivanesan` manisnesan

🎯
Focusing
View GitHub Profile
@manisnesan
manisnesan / 03_vectors.clj
Created August 29, 2014 04:39
Clojure-Vectors
(ns koans.03-vectors
(:require [koan-engine.core :refer :all]))
(meditations
"You can use vectors in clojure as array-like structures"
(= 1 (count [42]))
"You can create a vector from a list"
(= (list 1) (vec '(1)))
@manisnesan
manisnesan / 04_sets.clj
Created August 29, 2014 04:40
Clojure-Sets
(ns koans.04-sets
(:require [koan-engine.core :refer :all]))
(meditations
"You can create a set by converting another collection"
(= #{3} (set '(3)))
"Counting them is like counting other collections"
(= 3 (count #{1 2 3}))
@manisnesan
manisnesan / 05_maps.clj
Last active August 29, 2015 14:05
Clojure-Maps
(ns koans.05-maps
(:require [koan-engine.core :refer :all]))
(meditations
"Don't get lost when creating a map"
(= {:a 1 :b 2} (hash-map :a 1 :b 2))
"A value must be supplied for each key"
(= {:a 1} (hash-map :a 1))
@manisnesan
manisnesan / 06_functions.clj
Created August 29, 2014 04:56
Clojure-Functions
(ns koans.06-functions
(:require [koan-engine.core :refer :all]))
(defn multiply-by-ten [n]
(* 10 n))
(defn square [n] (* n n))
(meditations
"Calling a function is like giving it a hug with parentheses"
@manisnesan
manisnesan / 07_conditionals.clj
Created August 29, 2014 04:57
Clojure-Conditionals
(ns koans.07-conditionals
(:require [koan-engine.core :refer :all]))
(defn explain-defcon-level [exercise-term]
(case exercise-term
:fade-out :you-and-what-army
:double-take :call-me-when-its-important
:round-house :o-rly
:fast-pace :thats-pretty-bad
:cocked-pistol :sirens
@manisnesan
manisnesan / 08_higher_order_functions.clj
Created August 29, 2014 21:38
Clojure-Higher Order Functions
(ns koans.08-higher-order-functions
(:require [koan-engine.core :refer :all]))
(meditations
"The map function relates a sequence to another"
(= [4 8 12] (map (fn [x] (* 4 x)) [1 2 3]))
"You may create that mapping"
(= [1 4 9 16 25] (map (fn [x] (* x x)) [1 2 3 4 5]))
@manisnesan
manisnesan / 09_runtime_polymorphism
Created August 31, 2014 16:41
Clojure-Runtime-Polymorphism
(ns koans.09-runtime-polymorphism
(:require [koan-engine.core :refer :all]))
(defn hello
([] "Hello World!")
([a] (str "Hello, you silly " a "."))
([a & more] (str "Hello to this group: "
(apply str
(interpose ", " (concat (list a) more)))
"!")))
@manisnesan
manisnesan / sum-of-products-of-consecutive pairs of the first 1000 odd integers
Created October 1, 2014 20:57
Find the sum of the products of consecutive pairs of the first 1000 odd integers.
(reduce +
(map
(fn [pair] (* (first pair) (second pair)))
(take 1000
(partition 2 1 (filter odd?
(iterate inc 0))))))
@manisnesan
manisnesan / palindrome.clj
Last active August 29, 2015 14:07
Write a function to find out if a string is a palindrome–that is, if it looks the same forwards and backwards.
(defn isPalindrome
[inputStr]
(= inputStr (apply str (reverse inputStr))))
2014-10-30 13:34:56,682 ERROR api.LWEStatusService -
org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: String index out of range: 0
at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:780)
at com.lucid.servlet.LweCoreContainer.checkProps(LweCoreContainer.java:84)
at com.lucid.servlet.LweCoreContainer.getCoreByCollection(LweCoreContainer.java:70)
at com.lucid.servlet.LweCoreContainer.getCore(LweCoreContainer.java:33)
at com.lucid.api.CollectionInfoServerResource.doInit(CollectionInfoServerResource.java:91)
at org.restlet.resource.Resource.init(Resource.java:706)
at org.restlet.resource.Finder.handle(Finder.java:243)
at org.restlet.routing.Filter.doHandle(Filter.java:159)