Fork me on GitHub
#beginners
<
2015-11-30
>
andrut02:11:21

@revivek: the first feedback I could give is: get rid of dynamic variables simple_smile they're not really needed there; unlike in OOP (arguably), Clojure discourages you to have any state - in your example it doesn't change much but in the larger project it can cause unnecessary complexity

chadhs02:11:27

if you’re doing lein repl in a terminal is there a way to clear the screen/buffer so you’re not constantly typing at the bottom of the screen?

chadhs02:11:55

⌘k works in iTerm, but when you start typing it reverts to the old bottom of screen position 😞

games02:11:42

anyone have thoughts on http://purelyfunctional.tv for a clojure newbie? i work with JS daily, and never really used much in the way of a functional language, just for funsies

roberto03:11:54

it is pretty good for beginners. Eric Normand is a great teacher.

revivek03:11:24

@andrut: thanks! Those declarations were inspired by a tutorial online and I was suspicious about why it was done that way with dynamic variables. Glad to have more context

revivek03:11:41

What are thoughts on appropriate :pre :post usage? It's neat. Curious about particularly useful or frivolous usage patterns

seancorfield04:11:07

We haven't found them to be particularly useful in (30kloc) production code.

seancorfield04:11:43

We've tried pre/post, Prismatic Schema, and core.typed on and off at various times.

seancorfield04:11:29

We found pre/post didn't really give useful enough error messages and the code looks a bit cryptic.

seancorfield04:11:26

Having explicit tests (on inputs and outputs) made us think more deeply about what we were testing and whether the conditions actually mattered at all.

roelof06:11:05

Chips. I have now this code ;

roelof06:11:01

but still this error : IllegalArgumentException Don't know how to create ISeq from: java.lang.Long clojure.lang.RT.seqFrom (RT.java:528)

roelof06:11:24

some one a tip where the problem is and how to solve it

roelof07:11:32

good morning simple_smile

seancorfield07:11:11

@roelof: you're so close. Instead of identity you need recursion.

roelof07:11:08

@seancorfield: thanks, I will think again how to make a recursive function there

roelof07:11:23

I do not have the feeling that im soo close

noonian07:11:30

@roelof: I’m suprised that you’re getting that error. Your code looks like it wouldn’t error it just might not do what you want. Maybe the :gen-class is causing something to be messed up? The error you are getting I would expect you to get if you called testing as in your example but left off the quote. Maybe try again after running lein clean?

cjmurphy07:11:19

Just make the function you need at 'identity' the same as the function you need to write.

noonian07:11:26

ah, nevermind

seancorfield07:11:49

@noonian: no, he's getting it because mapcat tries to concatenate non-sequences.

noonian07:11:00

right, I just realized that; my bad

seancorfield07:11:49

@cjmurphy is saying the same as me :)

roelof07:11:23

?? I tested if list is a seq so why do I concenate non-seq ?? now im totally confused

noonian07:11:13

mapcat will call concat on the elements of list, not on list itself

cjmurphy07:11:57

Recursion is totally confusing. Sorry but it is supposed to be hard. But then slowly you get better with lots of practise, I hope...

roelof07:11:49

oke, so I have to pull one item out of the list and check if that is a seq

roelof07:11:00

then I could need map or again map-cat

seancorfield07:11:37

No your function is almost correct as is.

noonian07:11:39

you really are very close!

roelof07:11:45

@cjmurphy: I also hope it. Otherwise I get very hard days when I want to use clojure on daily basis with some projects

seancorfield07:11:50

Just change identity for another function.

seancorfield07:11:57

To make testing recursive.

cjmurphy07:11:13

Right at the deepest there is no list, yet mapcat needs a function that returns a list.

roelof07:11:35

oke, I will check the cheat-sheet again and again

seancorfield07:11:35

Somehow testing needs to cause itself to be called recursively (to deal with nested sequences)...

roelof07:11:23

oke, then I think I need the if then another time

roelof07:11:51

This is a very hard one and not a easy one like 4clojure says

seancorfield07:11:44

Well it's a "simple" one and if you understand recursion then it's "easy".

roelof07:11:35

yeah. yeah

roelof07:11:31

This one costs me almost a week to solve

noonian07:11:36

And I don’t think you need the cheat sheet anymore. Your function is almost correct.

seancorfield07:11:20

Just change one word to make testing recursive... That close!

roelof07:11:12

then I think to change identity but I have to think hard what to change to

roelof07:11:41

I changed mapcat to map but then I see the same output as input

noonian07:11:48

what does it mean for a function to be recursive?

roelof07:11:12

that it calls itself till the seq is all processsed

noonian07:11:30

Right. The only problem with your solution is that testing does not call itself.

seancorfield07:11:14

@roelof don't change mapcat just change identity

seancorfield07:11:27

That's the only thing you need to change.

roelof07:11:34

oke. I tried a few seconds to (mapcat testing list) and the first part looks good

roelof07:11:55

now I try to map or map-cat the whole seq

seancorfield07:11:00

Yes. Now testing is recursive.

roelof07:11:39

thanks, I have now this : https://www.refheap.com/112200 and see this error : CompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long, compiling:(C:/Users/rwobb/IdeaProjects/clojure-exercises/src/clojure_exercises/core.clj:13:1)

seancorfield07:11:32

Why did you add that mapcat on the outside?

roelof07:11:03

Because I need a way to process the whole input seq

seancorfield07:11:36

What you posted before was almost correct. You only needs to change identity to testing. Nothing else.

seancorfield07:11:47

No other calls needed adding.

roelof07:11:43

oke, but then I see this output : (testing '((1 2) 3 [4 [5 6]]) ) => (1 2 3 [4 [5 6]])

roelof07:11:55

and I need ( 1 2 3 4 5 6)

noonian07:11:22

ok, still a bug then but you are closer!

seancorfield07:11:25

Use () instead of [] like 4clojure does

roelof07:11:35

or do I need a function to convert the [ ] to a list

seancorfield07:11:37

(Just to test that)

seancorfield07:11:14

Because () is a seq but [] is not (it's a vector)

seancorfield07:11:48

That 4clojure exercise doesn't use vectors as I recall.

noonian07:11:28

this is just one of those things you need to learn about Clojure

seancorfield07:11:57

(or (seq? list) (vector? list)) would make it work for [] too btw.

noonian07:11:40

you might try using sequential? instead of seq?

roelof07:11:59

it using vectors : here is the challenge : (= ( '((1 2) 3 [4 [5 6]]))

seancorfield07:11:02

Ok so use the expanded condition I provided

roelof07:11:04

the whole thing : (= ( '((1 2) 3 [4 [5 6]]))

noonian07:11:06

(seq? [1 2 3]) ;=> false, (sequential? [1 2 3]) ;=> true, (seq? (seq [1 2 3])) ;=> true

seancorfield07:11:06

Ah maybe I used sequential? when I solved it. I'm doing all this from memory since I'm on my phone (it's bedtime here).

noonian07:11:36

Even with input lists it won’t work because in the base case you create a vector when the element is not a list.

seancorfield07:11:18

= compares values not types

noonian07:11:50

But your logic is entirely correct @roelof, its just seq? returns false for vectors which may be counter-intuitive.

seancorfield07:11:52

So (= [1 2 3] '(1 2 3)) is true

roelof07:11:50

yes, chancing seq? to sequential? did the job

roelof07:11:59

everything is working well

roelof07:11:03

thanks all

roelof07:11:19

@seancorfield: have a good night sleep

seancorfield07:11:19

Ok I can sleep soundly now :)

roelof07:11:16

one remark : most of the people I follow use coll? instead of sequential?

cjmurphy07:11:24

coll? is used in most of the ones I followed. And that's what my solution used.

cjmurphy07:11:47

Same - some used sequential? as you say.

noonian07:11:50

the difference is coll? will return true for sets as well

trancehime07:11:06

i'm not going to bed!

roelof07:11:39

@noonian: seancorfield is going to bed

noonian07:11:48

I understand now. simple_smile

roelof07:11:15

next challenge : calculate factorials, that is a easy one with resursion

cjmurphy07:11:25

And you might want to flatten a set so coll? is the better thing to use? In this case and prolly generally as well??

roelof07:11:15

cjmurphy: thanks for the lessons

trancehime07:11:09

I have a question

trancehime07:11:03

Assuming I have some vector like this: [{:data data} {:data data} {:data data}]

trancehime07:11:41

i would like to merge some additional data :data2 0 :data3 3 to each of the items inside that vector.

trancehime07:11:50

would i do a doseq

cjmurphy08:11:10

(merge or (assoc

trancehime08:11:21

Yeah, I would use merge or assoc to put in the data

trancehime08:11:36

how would I iterate that for each item in the vector

trancehime08:11:52

without exploding anything by accident

trancehime08:11:58

so map is OK?

noonian08:11:18

I think you want to think about transforming the sequence. So you want to return a new sequence so for or map makes sense. doseq is only used for side effects and returns nil.

trancehime08:11:50

cause I have to get a sequence of data from a database and then add extra stuff to each item in the sequence before I put it into a ratom

noonian08:11:52

and then for updating you could use assoc or merge or update depending on what you need to do

cjmurphy08:11:02

map is to be used for everything. That's my understanding.

trancehime08:11:13

yeah. I have used map before for simpler task

noonian08:11:48

for has the same syntax as doseq except that it returns a sequence of the body instead of just executing it for side effects.

cjmurphy08:11:22

Sounds perfect for map. Keep same size of a coll but change the things it is made of.

trancehime08:11:47

OK, so map it is

cjmurphy08:11:55

for is for when you really need some power...

adam_cameron08:11:39

@seancorfield: when we were talking about unit testing before (this is a month or so ago now), was it clojure.test you recommended?

adam_cameron08:11:07

which... um... by the sounds of it is built-in anyhow?

cjmurphy08:11:20

@adam_cameron: he might be answering you tomorrow morning his time.

trancehime08:11:04

hmm... defonce.

noonian08:11:14

clojure.test is built in though, and probably a safe choice

adam_cameron08:11:20

Cheers @cjmurphy, I know Sean pretty well and know when he's likely to pay attn to me. There's no rush with this.

noonian08:11:08

@trancehime: defonce is useful especially in cljs when you don’t want something to be redefined if the code is reloaded. You mentioned you were using reagent, so you might use defonce if you were using figwheel to auto reload your code and you didn’t want your application state to be reset every time.

adam_cameron08:11:47

I am, of course, open to others' opinions on my Q too. It was just we were specifically talking about it. I'd landed on Midje as an option, but he didn't seem to think it was particularly Clojure-ish (my wording, not his), and said "just use x"

noonian08:11:40

My advice is to just use clojure.test

trancehime08:11:31

@noonian: Yea, I know. Just thinking about atom persistence mostly

adam_cameron08:11:36

I think coming from a n00b 101 standpoint, it makes sense to get used to the baseline tools anyhow

noonian08:11:35

and cljs.test has a very similar api to clojure.test and is also built-in

roelof08:11:21

again a beginners problem : how I can make acc work in this code : https://www.refheap.com/112203

noonian08:11:28

You aren’t binding acc to 1 there, it is just in the body of the let expression. The syntax of the bindings for loop is a vector of <symbol0> <val0> <symbol1> <value1>.

noonian08:11:47

so (loop [number number, acc 1] …)

roelof08:11:50

Now I have to look how to make a Bigint of it. Now I see a integer overflow even on small numbers

roelof08:11:35

found it add a N after the initial number

roelof08:11:57

Can my code be improved ?

noonian08:11:49

can you post your corrected version?

noonian08:11:49

Looks fine imo except for small style convention things.

roelof08:11:17

@noonian: shoot so I can learn from it

noonian08:11:55

I would probably format it like this: https://www.refheap.com/112205 I renamed number to n inside the loop just so its less to type and might be less confusing to not shadow the variable. I also switched the order of n and acc in the multiplication because I think n will usually be smaller. I have no idea whether that matters on the jvm (probably not) but it feels nicer to me. Hehe anyway a lot of that is personal preference so feel free to develop your own personal style.

roelof08:11:01

o, I will but sometimes it's nice to hear feedback from more experience users

roelof08:11:48

so thanks from a cold and wet Netherlands

roelof08:11:25

now the next challenge to think about. How to interleave two seq without using interleave

roelof08:11:46

so a lot of thinking and reading to do

noonian08:11:12

Well, I’m off to bed. Goodnight and stay warm!

trancehime09:11:06

wow that video was incredibly enlightening

cjmurphy10:11:27

Which video was that?

trancehime10:11:32

https://www.youtube.com/watch?v=vpJCytVQgGs <-- This video, since I was trying to understand sente

roelof11:11:36

looks good but do you have first learn react before you can follow this videos ?

roelof14:11:45

I have to re-implement interleave as exercise of 4clojure. Could this be done with a loop recur loop or am I on the wrong track

adam_cameron14:11:57

Wow. Definitely being made to feel quite thick trying to get underway with Clojure (cc @andymyers). Googling for StackOverflow answers is all right, but when I read the (accepted) answer and just go "um... OK, I know understand things less than I did before" is an interesting turn up for the books.

swizzard14:11:56

there are some really great books, if you’re looking @adam_cameron

roelof14:11:04

@adam_cameron: who is playing dirty with StackOverflow answers.

adam_cameron14:11:14

Oh, I'm sure the answer is fine

swizzard14:11:28

this looks not wrong but also Too Much

swizzard14:11:57

like they should’ve moved the ‘use (require ‘[foo….]) in the REPL, (ns…(:require [foo….])) in files’ part to the top

adam_cameron14:11:29

And to be fair, I'm not experimenting coherently... I'm just messing around randomly at lunchtime. Was just trying to get this example from (https://clojure.github.io/clojure/clojure.test-api.html) working (is (= 4 (+ 2 2)))

adam_cameron14:11:58

(in the REPL) and when it errored, twigged I needed to import the clojure.test lib somehow, and was getting same error as per that question.

adam_cameron14:11:11

I'm glad you think the answer had "Too Much", btw

adam_cameron14:11:55

yeah, I was kinda expecting what you suggested, and then "and if you want a more thorough explanation, it's like this, see..."

adam_cameron14:11:27

But I have finally established that - yes - 2+2 = 4. So I'm happy now simple_smile

adam_cameron14:11:09

(I take my wins if and when I can get 'em)

roelof14:11:21

someone who can help me with my problem I posted earlier

swizzard14:11:06

@roelof loop + recur doesn’t sound unreasonable

roelof14:11:19

oke, then I wil try it that way

roelof14:11:53

The last easy exercises from 4 clojure are not so easy for a beginner

roelof14:11:07

but there are a nice challenge and I like a challenge

roelof15:11:12

hmm, I can take the first of each map with first but can someone give me a tip how I can make something like this of it '(1 :a ) where 1 is the first of the first list and :a the first of the second list

cjmurphy15:11:17

map can be used with two lists.

cjmurphy15:11:05

, and will do exactly that - map the function obviously.

cjmurphy15:11:52

Any number of collections - your map function just has to accept the same number of arguments as maps

roberto15:11:27

map or reduce will do it for you. I don’t know if there is a function in core that does that, but if there were, it would be implemented with either map or reduce.

roelof15:11:42

oke, i have to think carefully how the function looks like

roelof15:11:16

maybe something like fn[list1, list2. solution ) (conj solution (first list1) (first list2)) [] ) just right out my head

roelof15:11:03

@roberto: there is a function interleave but that one is not allowed to use

roberto15:11:12

ah, thanks

roberto15:11:00

you can cheat and view the source simple_smile.

roelof15:11:18

I did and they use lazy-seq and cons

roelof15:11:41

but I do not like to cheat. I get the feeling that I copy past things and learn nothing

roelof15:11:13

@roberto: or do you have another oponion

roberto15:11:41

hehehe, yeah, I would use reduce

roberto15:11:11

you can do it with both reduce and map. The reason my first choice is reduce is because it is more “semantic” to the problem you have.

roberto15:11:34

You are trying to reduce a map to a list of its keys and values.

roberto15:11:09

Well, map also makes sense semantically: You are trying to map a hash to a list of keys and values.

roelof15:11:17

I see more that reduce is more used then map

roberto15:11:45

but with reduce:

(reduce my-fn-that-does-the-work [] my-list)

roelof15:11:32

oke, as I said then I have to think about how the fn-that-works looks like

roberto15:11:38

the fn would look like: (fn [acc it] …..) I use it as a short name for iterator.

roberto15:11:52

and acc as short for accumulator.

roelof15:11:23

and in the exercise there are two maps like this : (= (__ [1 2 3] [:a :b :c]) '(1 :a 2 :b 3 :c))

roelof15:11:44

chips . now I see emicons 😞

roberto15:11:48

ah, I see. simple_smile

roberto15:11:51

hehehe, use markdown

roelof15:11:18

I will google how to make this work with markdown

roberto15:11:37

I mean, use markdown in slack to paste code

roberto15:11:48

then you won’t have emoticons inserted where you don’t wnt them.

roelof15:11:54

I know that tou mean that

roelof15:11:04

but im not so familiar with markdown

roelof15:11:25

@roberto: that is better

roelof15:11:36

I changed my code

roberto15:11:15

btw, reduce can take 2 functions:

(reduce #(cons %2 %1) [1 2 3] [4 5 6])

roberto15:11:43

I meant 2 collections, not 2 functions

roelof15:11:41

oke, im now playing with your example

roberto15:11:46

so, look into reduce and into . I can’t give you more hints without giving away the entire solution.

roelof15:11:50

Do not do that, That spoils the fun for me

roelof15:11:24

I was thinking about using first

roelof15:11:55

like this (reduce #(cons (first %1) (cons (first %2))) [1 2 3] [4 5 6]) but then this error message : CompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long

roelof16:11:52

also (reduce #(into () (first %1) (first %2)) [1 2 3] [4 5 6]) gives the same error message

roberto16:11:41

because %1 isn’t a seq

roberto16:11:51

you don’t get a list inside the fn

roberto16:11:09

you get an item inside the collection, and in this case, none of the items is a seq.

roelof16:11:20

oke, I wiil try another idea

roberto16:11:04

so, here is a hint. With fp languages, you can step through the evaluation of each iteration.

roberto16:11:33

so, go through the first iteration, and try to figure out what the values of %1 and %2 will be

roelof16:11:43

@roberto: they schould be [2 3] and [ 5 6] but I get the feeling they do not are

roberto16:11:58

they are not

roelof16:11:00

sometimes fp makes me grazy

roberto16:11:09

so, think about how reduce works

roberto16:11:17

the function, what is its signature?

roelof16:11:24

I think you mean this [f val coll]

roelof16:11:51

so reduce function list

roelof16:11:32

@roberto: is this what you mean

roberto16:11:06

(acc it) -> Something

roberto16:11:22

first arg is an accumulator, and the second is the item in the collection(s) for that iteration

roelof16:11:02

oke, that I understand

roelof16:11:30

acc is the outcome what we want and it is the current item we have to do something with

roelof16:11:13

but we see acc and it never on the code , that makes it so difficult for me

roberto16:11:51

Remember %1 is the first arg

roberto16:11:19

So that is your accumulator

roelof16:11:02

%2 is then the first map

roberto16:11:05

That is why I don't like using % for code examples, and instead use good names

roberto16:11:46

And, if you pass it 2 colls then you would have another arg I think

roelof16:11:14

oke, now I see what is going wrong , I need two variables one for coll 1 and one for coll2

roberto16:11:19

actually, I’m wrong, it doesn’t provide another arg simple_smile

roelof16:11:14

?? so do we need a variable for the acc, one for coll2 and one for coll2 or do I misunderstood you

roelof16:11:29

right now I have 2 variables

roberto16:11:12

I was wrong. Sorry pairing right now

roelof16:11:41

oke, still thanks for your time and patience

roberto16:11:23

Btw, I might be wrong about reduce. More and more it seems like map is the better option

roberto16:11:55

Map can take more than one call also

roberto16:11:03

Have tiger back to work

roelof16:11:39

oke, this one (map #(into %1 (first %2) (first %3)) [] [1 2 3] [4 5 6]) gives a empty set

roelof16:11:44

so we are close

eugene16:11:51

Hi Clojurians simple_smile

eugene16:11:13

What’s the simplest way to flatten a json? Don’t want to reinvent the wheel here

seancorfield16:11:03

@adam_cameron: yup learn clojure.test first then maybe look at Expectations if you want cleaner syntax

seancorfield16:11:56

Also clojure.test.check (a contrib library, the next thing to "built-in") for some powerful testing constructs.

seancorfield16:11:07

@roelof: remember that map iterates over all it's collection arguments at once and stops when the shortest one ends (`[]` in your case).

roelof16:11:23

oke, so map is not the one im looking for

roelof16:11:48

@seancorfield: Maybe use reduce

roelof16:11:23

or do what the orginal does use lazy-seq

roelof17:11:47

@seancorfield: is there somewhere a good tutorial about clojure.test ?

seancorfield17:11:35

Not that I know of (re: clojure.test).

seancorfield17:11:21

So the current problem is interleave? You have two (or more) collections and you want to take an item from each one in sequence and then flatten the result...

seancorfield17:11:51

So map sounds sort of right… except you’ll want to flatten the grouped items so that sounds more like mapcat

seancorfield17:11:14

So we’re looking at (mapcat some-function coll1 coll2) I think...

seancorfield17:11:07

and some-function needs to take two arguments (in this case) and return a pair of the values

seancorfield17:11:26

when you had (map #(into %1 (first %2) (first %3)) [] [1 2 3] [4 5 6]) you have two missteps there: you’re attempting something reducey assuming [] is an accumulator; and calling first which map does for you essentially

seancorfield17:11:11

But reduce only takes one collection so you can’t use it here (unless you use map on the collections to make pairs anyway).

seancorfield17:11:55

So back to some-function: what’s the easiest way to take two things and produce a pair? (fn [a b] (??? a b)) — what is ??? here?

roelof17:11:21

@seancorfield: moment, im just back from dinner and now looking for a function that can do that

roelof17:11:19

the outcome is (a b) seancorfield

roelof17:11:33

then im thinkig of set

roelof18:11:44

@seancorfield: nope, set is not the right one 😞

roelof18:11:55

back to the cheat-sheet

seancorfield18:11:16

Is [a b] a pair of values?

seancorfield18:11:46

Is there a function that, given a and b, would produce [a b]?

roelof18:11:51

it must be, im still looking and testing candidates set and conj are not the right one

roelof18:11:11

hmm I was checking at join but cursive does not know join 😞

seancorfield18:11:49

Hmm, what function would create a vector from a given number of elements? simple_smile

roelof18:11:03

aha, the function vec

seancorfield18:11:25

How many arguments does vec take?

seancorfield18:11:16

vec turns a collection into a vector

seancorfield18:11:38

You need something (similar) that takes a number of arguments and returns a vector of them all together

roelof18:11:45

mapv looks promosing

roelof18:11:37

am I right that it must be in the create section of vectors on this page : https://jafingerhut.github.io/cheatsheet/grimoire/cheatsheet-tiptip-cdocs-summary.html

noonian18:11:18

have you checked out the apropos function from the repl?

noonian18:11:00

You can do something like (apropos #”vec.*”) and it will return all the functions that match the regex

roelof18:11:16

oke, that way

roelof18:11:29

then it must be vector or vector_of

roelof18:11:48

and it is vector_of . Then I see the right output on a test

roelof18:11:36

(mapcat (fn [a b] (vector a b)) [:a :b] [2 3 ] ) gives (:a 2 :b 3) which looks good to me

noonian18:11:15

You could even remove the anonymous function and just pass vector to mapcat also.

roelof18:11:03

hmm, (mapcat (vector [:a :b] [2 3 ] )) do not give the right answer

noonian18:11:58

I mean, (mapcat vector [:a :b] [2 3]) is the same as (mapcat (fn [a b] (vector a b)) [:a :b] [2 3 ])

noonian18:11:29

since vector is itself a function that can take two arguments

roelof18:11:25

oke, that way

roelof18:11:47

thanks for learning me that , I did understand what you mean, My fault

noonian18:11:07

no problem, it wasn’t obvious for me when I first started with Clojure either

roelof18:11:37

but it worked

roelof18:11:44

learned another thing

roelof18:11:39

he, is 4clojure down or is my internet doing wierd things

noonian18:11:39

seems to be working for me

roelof18:11:57

I see a 404 on the Edge browser

roelof18:11:02

I will try FF

roelof18:11:36

also ping on the prompt gives a not found error message

roelof18:11:03

and also refheap is not working anymore

noonian18:11:35

I think its your internet or something 😕

roelof18:11:47

@seancorfield: I found your answer on clj-time

roelof18:11:59

with dt you mean the actual date

roelof18:11:05

I think also

seancorfield18:11:07

Your clj-time object, yes.

seancorfield18:11:56

So if you have a Joda Time object my-date-time (a date / time), you can require clj-time.coerce as tc and then call (tc/to-date my-date-time)

seancorfield18:11:41

Some libraries have automatic conversions for Joda Time (java.jdbc for example, via a namespace in clj-time).

roelof18:11:50

oke, but I have only a date like this ; 01-05-2015

seancorfield18:11:00

You mean a string?

roelof18:11:24

I think so. I use now datomic as my database driver

seancorfield18:11:05

Brave, learning Datomic as well as everything else simple_smile

roelof18:11:18

joda time is also a dependency for datomic

roelof18:11:42

my first priority is learning clojure.

roelof18:11:59

If I have time left I play a little with datomic

seancorfield18:11:13

I haven’t even started playing with Datomic yet!

roelof18:11:43

I thought it was the best one for a financial app but I have doubts

seancorfield18:11:52

(BTW, I maintain clj-time — in case you have any questions — as well as clojure.java.jdbc and congomongo, in case you want to try a SQL DB or MongoDB)

roelof18:11:26

but for jdbc you need knowlegde about sql and joins and I do not have that

roelof18:11:44

I have played a little bit with Mongo when trying node but do not think it suitable for a accountiing/financial app

roelof18:11:10

where ACID is needed according to some pages on the net

roelof18:11:16

@seancorfield: that is why I play a little in Datomic

roelof18:11:44

I did follow a little course on the language and it's not so difficult

nando19:11:58

@roelof : There is a good tutorial for clojure.test on http://purelyfunctional.tv

roelof19:11:30

oke, I will bring my daugther to bed and look if I can find the course

nando19:11:04

Unfortunately I have to work … 😞

nando19:11:40

Not much time to study this evening.

roelof19:11:31

oke, here no work anymore, ít's 20:00 hour here so time for tv and sleep in two hours

nando19:11:13

I’m in the same time zone as you, in Switzerland near Lugano, but I run my own company ...

roelof19:11:49

oke, then not much free time

nando19:11:00

which problem are you working on?

roelof19:11:32

4clojure but I solved it

nando19:11:29

That’s a fun one.

roelof19:11:41

I thought problem 30 could be solved by set but no

roelof19:11:08

so tomorrow thinking well which other function I can do

roelof19:11:38

@nando: Did you also learn clojure by 4clojure

nando19:11:28

@roelof: I haven’t “learned” clojure yet. I’m still working on it.

nando19:11:07

I’ve been hovering around the language for some time, not really clear how to get into it.

nando19:11:16

Living Clojure helped me a lot, somehow, I think simply because of the tone and pace of the book.

roelof19:11:16

oke, I did first the clojure koans and now the4clojure exercises

roelof19:11:33

I learn the best by doing things and read a little

roelof19:11:40

@nando : last question before I call it a day Which language do you then use in your own company/

nando19:11:16

CFML is the server language I know best. I do a lot of Javascript / jQuery, and I’m looking to swap that out with a React solution.

nando19:11:52

… at least in some parts of the main application I’m developing and maintaining.

roelof19:11:11

oke, for my clojure and programming is a hobby

nando19:11:40

Oh, that’s nice. No pressure then ...

roelof19:11:57

but thanks for the help. IM going watchig tv and in 2 hours to bed

roelof19:11:13

no, onluy pressure from myself

nando19:11:34

Ok, ciao roelof

roelof19:11:40

and who knows when Im better in clojure I find a job in it in the Netherlands

nando19:11:17

If you stick with it for some time, eventually you’ll be good enough to work at it.

nando19:11:34

I think it’s good you don’t know anything else, to tell you the truth.

nando19:11:14

By the way, you asked about learning React earlier. Here’s a REALLY good tutorial for that.

Tim19:11:00

yes, this react course is THE BEST

Tim19:11:07

one of the best video courses I taken

Tim19:11:12

I still haven’t finished it yet

Tim19:11:35

that guy is so good

nando19:11:14

(= that-guy “Stephen Grider”)

nando19:11:50

He also has a course on React Native

Tim19:11:32

yeah I got that

Tim19:11:53

man I with we could get Stephen into clojure so he could make videos on that

Tim19:11:10

I would watch his class on anything

nando20:11:04

@tmtwd : Ask him 😉

rcanepa20:11:18

Hi everyone… Does anyone knows if there is a Clojure function to update a map key or create the key if it doesn’t exist?

rcanepa20:11:31

Something like update merged with assoc

rcanepa20:11:52

I need to update (or create) a key in a nested map.

roelof20:11:21

@nando thanks for the tip. I think I first learn clojure and then look into react or om

cjmurphy20:11:26

@rcanepa: How about assoc-in? It will create the key if it doesn't exist.

rcanepa20:11:50

If I use assoc-in I will replace the old value

rcanepa20:11:34

With update-in I can increment/update the value, but I get an error if the key doesn’t exist

cjmurphy20:11:24

(update-in {:items {:hp-potion 2}} [:items] identity)

roelof20:11:54

@cjmurphy is cljs.user your prompt. Just a question out of curoisity

cjmurphy20:11:08

Yes, just got rid of.

cjmurphy20:11:51

Your update-in function (here using identity) can do what it wants.

cjmurphy20:11:36

So it can check for existence of key and add if not there

roelof20:11:02

@cjmurphy: thanks, when I use your example it looks like nothing is updated

roelof20:11:14

sorry to hijack this topic

cjmurphy20:11:40

identity just returns itself. Instead of identity you can put a function that looks at what is coming in and returns something different.

cjmurphy20:11:11

I mean - returns what it is passed in.

roelof20:11:23

oke , thanks

roelof20:11:46

maybe a idea I can work on later

rcanepa21:11:31

Oh… great, something like that is what I was looking for. Thanks @cjmurphy !

seancorfield21:11:58

Check out fnil

seancorfield21:11:32

That allows you to provide a value to be used if an argument is nil/missing.

seancorfield21:11:14

So (fnil inc 0) is a function that increments a value but if the value is nil it substitutes zero (and then increments that).

trancehime22:11:49

>looks good but do you have first learn react before you can follow this videos ? @roelof Not really, if you're just interestrd in async

eraserhd22:11:59

fnil is the awesomest function I never remember to use.

andreortiz23:11:35

anyone familiar with boot-middleman?

andreortiz23:11:15

I have some questions around setup… examples I’m finding aren’t running. Not sure if it’s an ENV issue