Fork me on GitHub
#beginners
<
2018-02-05
>
alexmiller01:02:16

oh, I see what you’re asking. (on your 2nd one, you shouldn’t ever expect [org.ocpsoft.prettytime/prettytime-parent "LATEST"] to work)

alexmiller01:02:38

It’s probably that LATEST is finding the latest snapshot for some reason

seancorfield01:02:41

It does the same even if you use RELEASE (which should not ask for snapshots).

seancorfield01:02:10

boot -d org.ocpsoft.prettytime/prettytime-nlp:4.0.1.Final repl
goes off looking for snapshots too... 😞

alexmiller01:02:30

yeah, LATEST refers to either release or snapshot

alexmiller01:02:23

I don’t think maven 3.x even supports LATEST or RELEASE any more, but maybe Aether does

shaun-mahood05:02:54

I should know this but it keeps messing me up. I've got a call to concat in the middle of a function that returns a string. I can't for the life of me figure out where to add doall to get it to return something other than [email protected]. Is doall the wrong thing to use here or am I just missing something obvious?

noisesmith18:02:01

the printed format is useless because the toString for a lazy-seq is the wrong thing in almost every case, doall only realizes the elements, it doesn’t put it into a non-lazy type so it doesn’t eliminate the problem

shaun-mahood05:02:18

I found https://stuartsierra.com/2015/04/26/clojure-donts-concat which I guess answers most of my question, but I'm still a bit unclear of when doall should work or not.

sundarj10:02:31

doall does not un-lazyseq a lazyseq, it just realizes it:

user=> (type (map prn [1 2 3]))
clojure.lang.LazySeq

user=> (realized? (map prn [1 2 3]))
false

user=> (type (doall (map prn [1 2 3])))
1
2
3
clojure.lang.LazySeq

user=> (realized? (doall (map prn [1 2 3])))
1
2
3
true

sundarj10:02:08

conversion can be done like normal (lazyseqs are still seqs):

user=> (vec (map prn [1 2 3]))
1
2
3
[nil nil nil]

shaun-mahood22:02:01

@U61HA86AG Thats's a fantastic explanation, thanks for the help. It's been on of the things that has tripped me up repeatedly but I've never taken the time to really try to understand it.

sundarj22:02:49

@shaun-mahood glad i could help 🙂

shaun-mahood05:02:35

Oh, and I guess I discovered how to use mapcat - I replaced my concat call with (mapcat conj) and it worked the same, then changed that into a transducer and it got rid of the laziness and works how I needed.

curlyfry10:02:04

@shaun-mahood I of course don't know your exact use case, but I think it might be slightly more idiomatic to use clojure.string/join if you're building a string from your mapcat call: (clojure.string/join (mapcat conj list-of-stuff))

curlyfry10:02:13

In fact a regular (str) call should realize the collection

noisesmith18:02:08

the hilarious thing is that when you call str on the return value of concat and get [email protected] it’s still realizing the whole thing (it has to in order to get the hash code it wants to print) - the issue isn’t the laziness or state of realization per se, it’s that toString for lazy-seq is the wrong thing, and you want the print-method (what eg. pr, prn or pr-str would produce) or to make your own string out of the elements in the lazy input

curlyfry06:02:15

I see, interesting!

timo16:02:18

Hi, I am using luminus to get started and wonder if I should use devcards. luminus has doo. Would you recommend to use devcards in conjunction with devcards or is it sufficient to use doo for starters?

timo16:02:43

BTW...it's a serious project, not only for fun...

shaun-mahood16:02:53

@timok: I like to use devcards as much in the design phase as anything else - https://juxt.pro/blog/posts/generative-ui-clojure-spec.html is probably the most compelling thing Ive seen (and used a bit) for devcards outside of the original talk

shaun-mahood16:02:00

I would be a bit hesitant to recommend it if you are using re-frame (unless you are up for a bit of extra work), since it doesn't play nice by default, but otherwise I'm a pretty big fan

timo16:02:14

alright...I do use re-frame. good to know...thanks!

shaun-mahood16:02:39

@timok: I've been using it recently to design my reagent components that I then use in re-frame - it's good for that since it forces you to consider the boundaries of the component and separate it from the application.

timo16:02:16

@shaun-mahood so when you have good separation it works fine?

shaun-mahood16:02:58

@timok: Yep - anything you want to build with base reagent (no re-frame subscription or handlers or otherwise) work great with it. There have been people who have gotten it working with re-frame but it requires some extra work that I haven't put the time in to figure out.

timo16:02:43

@shaun-mahood thanks! I'll try it out in a bit.

roelof17:02:01

What is the best way to learn clojure for a absolute beginner ?

roelof17:02:21

no book or course to learn the basics ?

joelsanchez17:02:10

that course will teach you the basics

roelof17:02:40

hmm, I find the last one lacking exercises so I can practice myself

roelof17:02:19

braveclojure looks fine. I hope only that the exercises are not too difficult for a beginner

roelof17:02:34

is there no such things like koans for clojure

roelof17:02:15

oke, then I think i will choose between the clojurekoans or brave

roelof17:02:25

any recommendations between these two

AT17:02:51

the koans are just to get used to the most elementary stuff

roelof17:02:27

oke, maybe first then the koans and later brave and in the meantime do some 4clojure ?

roelof17:02:36

sounds that like a good plan ?

didibus17:02:01

It does to me.

AT17:02:05

yeah, just get started and you'll figure out what you need as you go along.

didibus17:02:38

Just make sure you first master your setup, a repl properly integrated with your editor is mandatory to appreciate and get Clojure

roelof17:02:29

oke, I was thinking of using intelij with cursive or maybe even atom if that one has a repl

didibus17:02:57

Emacs with Cider if you already know emacs. Otherwise go with Atom + ProtoREPL, or IntelliJ Cursive.

AT18:02:46

Fwiw, the koans will work "out of the box" after you install java and, optionally, leiningen. No environment setup needed to get started! They're fairly quick and you can work through them in one day and revisit as needed for refresh. Once you're done with the koans, you'll be in a good position to think about an actual environment. I think that "environment setup" is a big obstacle to getting started in any programming platform but especially true for clojure.

AT18:02:22

I went down the emacs "rabbit hole" but heard nice things about lightmod (https://sekao.net/lightmod/), a self-contained environment for writing clojure/clojurescript.

roelof18:02:40

I have already set up intelij with cursive and it looks to work very well

roelof18:02:41

Thanks for the tip . Never heard of lightmod before

roelof18:02:56

hmm, is this koan right :

"When things cannot be equal, they must be different"
  (not= :fill-in-the-blank :roelof))

roelof18:02:48

it seems that you can put everything in it as long as it 's not ":fill_in_the_blank"

noisesmith18:02:18

isn’t that what the koan is demonstrating? it’s a very simple point but I don’t see what else it could be trying to do

roelof18:02:09

oke, it looks so simple that it cannot be true

roelof19:02:04

Still luminus the best choice if I ever wanted to make a website with clojure ?

justinlee19:02:23

@roelof there’s not really a consensus choice in the community. it kind of depends on what kind of website you want to make and how much experience you have in web tech. luminus is certainly a good choice from what i can see because it manages a lot of moving pieces and has a lot of documentation

bronsa19:02:46

that was quick :)

seancorfield19:02:03

Deactivated! (said in a Dalek voice as I watched Seasons 6 and 7 of Doctor Who over the weekend)

roelof19:02:00

@lee.justin.m I was thinking of making a website where households could keep track of the expenses and profits. Maybe later I could grow to a accounting system

roelof19:02:26

yep , something like that

roelof19:02:34

but not as a SPA

justinlee19:02:45

If you’re not going to do it as an SPA, luminus has a server-side html templating engine and database integration, which sounds like what you need. Note, I’ve only ever looked at the documentation, so I can’t testify to it. But it looks well supported and thought out.

justinlee19:02:22

if you are interested in an all-clojure stack from database to client, you might look at fulcro (again I haven’t used it). but these kinds of frameworks are pretty complicated and are a lot to bite off, so server-side templating might be easier way to ease into it.

roelof20:02:21

Fulcro looks difficult for a beginner so I think i will stick with luminus

roelof20:02:50

Is there also a library where I can make graphs/plots so I can let the user see what part of the expense is for example taxes ?

beta103620:02:28

what do you use when you need an eager list comprehension (that is when you need both the retun value as well as side effects)?

beta103621:02:41

would you prefer to rewrite a nested list comprehension using mapv, filterv, etc.?

greglook21:02:32

depends on the complexity of your logic, I suppose

greglook21:02:56

a while ago I trained myself out of using for and doseq because they expand into forms which are nearly impossible to cover with unit tests 😅

beta103621:02:44

do you create named functions to avoid nested loops?

greglook21:02:59

calling doall on your for expression is certainly the easiest approach here, though

beta103621:02:55

i wonder if there is a more or less canonical way to signalize that both the value and the side effects are important.

beta103621:02:12

i'm using vec, but i'm not sure it's clear enough that the point is not (just) a conversion to a vector.

roelof21:02:31

a clojure koan question :

roelof21:02:42

what do I do wrong here :

"You can create a set by converting another collection"
  (= #{3} (set 3))

roelof21:02:53

it still says assertion failed

beta103621:02:13

set needs a collection

alexmiller21:02:15

set expects a collection - you want hash-set

greglook21:02:19

set is like vec, not vector ☝️

roelof21:02:22

@alexmiller so I need to do hash-set {3} ?

beta103621:02:04

(hash-set 3)

roelof21:02:15

nope, when I do :

"You can create a set by converting another collection"
  (= (hash-set 3) (set 3))

roelof21:02:29

I see a message that the assertion has failed

roelof21:02:52

Now meditate upon C:\Users\rwobb\Documents\clojure\clojure_koans\clojure-koans\src\koans\05_sets.clj
---------------------
Assertion failed!
clojure.lang.ExceptionInfo: You can create a set by converting another collection
(= (hash-set 3) (set 3)) {:line 7}, compiling:(C:\Users\rwobb\Documents\clojure\clojure_koans\clojure-koans\src\koans\05_sets.clj:5:1)

beta103621:02:58

(= #{3} (hash-set 3))

beta103621:02:56

(= (set [3]) (hash-set 3))

roelof21:02:41

oke, that worked but I think it is cheating a little \

beta103621:02:18

(= #{3} (set [3])) works too, of course.

roelof21:02:10

the challenge was to solve this : ` (meditations "You can create a set by converting another collection" (= #{3} (set )) `

bronsa21:02:43

#{3} = (set [3]) = (hash-set 3)

roelof21:02:54

and why is it [3] and not '3`

bronsa21:02:09

because set takes a collection and puts its elements into a set

bronsa21:02:19

while hash-set takes any number of arguments and puts them into a set

bronsa21:02:50

[3] is a vector of that contains 3

bronsa21:02:16

you could've done (set '(3)) too, ("transforming" a list in a set)

bronsa21:02:39

or even (set #{3}), transforming a set into a set

motoom21:02:50

(set '(1 2 2 3))
works as expected

roelof21:02:37

oke, thanks, now time to sleep here

roelof21:02:15

tomorrow studiying maps and some other things