Re: Error in main using Stuart Sierra's Component when deploying to Heroku

2017-03-13 Thread 'Rickesh Bedia' via Clojure
The full error message is (when I look at the heroku logs) Exception in thread "main" clojure.lang.ExceptionInfo: Error in component :listener in system com.stuartsierra.component.SystemMap calling #'com.stuartsierra.component/start {:reason :com.stuartsierra.component/component-function-threw-

Error in main using Stuart Sierra's Component when deploying to Heroku

2017-03-13 Thread 'Rickesh Bedia' via Clojure
I am trying to start my clojure application on my heroku dyno but I keep getting and error in my stuartsierra.component/start. Below is my core file containing my main function. (defrecord Listener [listener] component/Lifecycle (start [component] (assoc component :listener (yada/listene

GraphQL - Clojure - resolver-fn

2017-03-13 Thread 'Rickesh Bedia' via Clojure
I am researching how to use graphql in clojure and it all seems to make sense, and I can follow the Demo Project, except for the resolver-fn In https://github.com/tendant/graphql-clj the resolver function is defined to be (defn resolver-fn [type-name field-name] (cond (and (= "Que

Changing value of atom vector using swap

2016-12-20 Thread 'Rickesh Bedia' via Clojure
I have (def data {:headers ["A" "B" "C" "D"] :rows [["1" "2" "3" "4"] ["5" "6" "7" "8"] ["9" "10" "11" "12"]]}) And I have a function (defn replace-value [struct] (clojure.walk/prewalk-replace {"3" "hello"} (struct :rows))) When I do (replace-value @data) > [["1" "2" "hello

Clojure.spec - Why should you use and when

2016-12-11 Thread 'Rickesh Bedia' via Clojure
Hello, I have recently watched Rich Hickeys talk at Cojure Conj 2016 (https://www.youtube.com/watch?v=oyLBGkS5ICk - here's the link in case anyone missed it) and although it was very interesting, I didn't really understand the point in Clojure.Spec or when you'd use it. It seemed like most of

Re: Index of an element in a vector of vectors

2016-12-08 Thread 'Rickesh Bedia' via Clojure
Is there a way to generalise? I.e a function that allows you to swap any of the 1-9? On Wednesday, 7 December 2016 18:06:19 UTC, Andy- wrote: > > One option is to use keep-indexed: > > (first > (keep-indexed > (fn [i xs] > (first > (keep-indexed > (fn [j x] >

Index of an element in a vector of vectors

2016-12-07 Thread 'Rickesh Bedia' via Clojure
If I have (def players [["1" "2" "3"] ["4" "5" "6"] ["7" "8" "9"]]) How would I get the index of number 5? I think it should be [1 1] but don't know how to get this If it were more simple such as (def players ["1" "2" "3"]) I can get the index using (.indexOf players "2") > 1

Re: Returning multiple values

2016-11-30 Thread 'Rickesh Bedia' via Clojure
ither of those will give > you your result. > > On 30 November 2016 at 10:34, Colin Yates > wrote: > > Ah, I just realised people is _not_ a sequence of maps but the result > > of calling '{:name "John" :age "25"}' passing in the other two maps

Returning multiple values

2016-11-30 Thread 'Rickesh Bedia' via Clojure
I have a definition: (def class1 {:people ({:name "John" :age "25"} {:name "Harry" :age "23"} {:name "Peter" :age "24"})}) The result I want is a vector that looks like [["John" "25"] ["Harry" "23"] ["Peter" "24"]] If I call

Re: Getting information from a hashmap that is inside anothe hashmap

2016-11-24 Thread 'Rickesh Bedia' via Clojure
. > > > 2016-11-22 11:42 GMT+01:00 'Rickesh Bedia' via Clojure > >: > > Lets say I have: > > (def human {:firstname "John" :surname "Smith"}) > > To get the firstname I would run (human :firstname) and this would give > >

Re: Saving the value of an atom

2016-11-23 Thread 'Rickesh Bedia' via Clojure
When I put @car into my table the value doesn't show? On Wednesday, 23 November 2016 13:32:56 UTC, Alex Miller wrote: > > In what way does it not work? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goog

Saving the value of an atom

2016-11-23 Thread 'Rickesh Bedia' via Clojure
(defonce car (atom "")) (defn car-colour [ ] [:div [:div.container [:div.span12 [car-form car]]] [:div.container [:div.span12 "The car colour is: " @car]] ]) I have this function where you type in the make of a car and then this goes to a database and returns the col

Getting information from a hashmap that is inside anothe hashmap

2016-11-22 Thread 'Rickesh Bedia' via Clojure
Lets say I have: (def human {:firstname "John" :surname "Smith"}) To get the firstname I would run (human :firstname) and this would give "John" However if I now have (def human2 {:name "Bob" :char {:eye-colour "brown" :hair-colour "red"}}) how would I get the eye-colour? Would it be (h

Using a function in another function

2016-11-10 Thread 'Rickesh Bedia' via Clojure
I have this function: (defn add1 [x] (+ 1 x)) which is just a very simple function that adds 1. I now want to create a new function called add2 that uses add1 twice. I have tried (defn add2 [x] (add1 (add1 [x])) but this doesn't work. (Can someone explain why this doesn't work. I think it

Clojure Web Applications for Beginner

2016-11-02 Thread 'Rickesh Bedia' via Clojure
Hi, I am fairly new to Clojure, only been learning about it for a around 2 months. I have mainly been spending my time learning through "Clojure for the Brave and True", Clojure Koans and 4Clojure. However, I have recently been reading about Clojure's use in creating Web Apps. I have been foll

get function

2016-09-13 Thread 'Rickesh Bedia' via Clojure
Hi everyone, I am new to Clojure and have been playing around with it for a little while. I have seen that (get [3 2 1] 0) and ([[3 2 1] 0) both return the value 3. Similarly (get {:a 0 :b 1} :b) and ({:a 0 :b 1} :b) return 1. I was wondering if anyone could explain why the get function is usef