Fork me on GitHub
#beginners
<
2016-05-02
>
agi_underground09:05:34

hi, can anyone tell me where i can find uptodate article about configuring emacs for clojure, maybe 2016 year?

plexus09:05:03

@agi_underground: I've been working on a beginners guide for Emacs that's "modern", i.e. uses ELPA/MELPA and use-package

plexus09:05:15

you can find the work in progress here http://emacs-berlin.org/curriculum.html

plexus09:05:35

into ~/.emacs.d/init.el you should be good to go

plexus09:05:07

The main thing is to get CIDER from MELPA, that's enough to have a working setup, so if you already have MELPA configured that can be as simple as M-x package-install cider

plexus09:05:22

After that I highly recommend some structural editing mode. Paredit is a good default. Alternatives are smartparens and parinfer

plexus09:05:01

drop into #C099W16KZ or #C0617A8PQ if you have any more questions

agi_underground10:05:42

@plexus: Thank you, article look nice, i hope it will be helpful for me!

jumar10:05:49

@agi_underground @plexus I’m not the expert, but isn’t the Emacs LIVE a good and “modern” option for hacking Clojure in Emacs while still being accessible for beginners?

plexus10:05:01

Emacs Live is woefully unmaintained, and is so idiosyncratic that I would not recommend using it.

plexus10:05:50

You'll be inheriting someone else's large and convoluted config, and spend a lot of time just figuring out. It comes with its own packaging/config system which nobody else uses.

plexus10:05:15

If you aim to do live performances with Overtone then maybe there's still a value proposition for Emacs Live. For general dev I don't think it's a great starting point though.

jumar10:05:53

Good to know - thank’s for sharing your opinion simple_smile

plexus10:05:34

if you really want a more full-fledged setup, then prelude is a decent option

bojan.matic11:05:25

what is the idiomatic way to map into a vector?

st11:05:08

(into [] your-sequence) Not sure to fully understand your question though.

plexus11:05:28

@bojan.matic: are you looking for mapv ?

bojan.matic11:05:18

i'm making a reagent component, and want to render a list of things

bojan.matic11:05:42

reagent components are represented as vectors

bojan.matic11:05:09

the todomvc uses a for

bojan.matic11:05:49

is that the recommended way to go?

plexus11:05:05

yeah a for is a good choice for this

bojan.matic11:05:30

if i wanted to do some data transformations and filters, what could i use then? or do i filter the data externally, then just use for in the render function?

plexus12:05:38

you can filter with for, it's basically a list comprehension

plexus12:05:42

(for [x [0 1 2 3 4 5]
      :let [y (* x 3)]
      :when (even? y)]
  y)

plexus12:05:44

or you can just use map and filter. It really depends on the specific case which version looks better. Both are totally valid.

bojan.matic13:05:58

can i get the index while doing for?

bojan.matic13:05:10

i need to create a unique key for every item in the list

bojan.matic13:05:01

thanks, already found it simple_smile

bojan.matic13:05:25

so i'm on the right track then

bojan.matic13:05:08

how do you return a hash-map literal from a shorthand function

bojan.matic13:05:30

(map-indexed #({:index %1 :item %2}) [1 2 3])

bojan.matic13:05:38

throws an Invalid arity: 1 error

bojan.matic13:05:12

using (map-indexed (fn [index value] {:index index :item value}) [1 2 3]), works

jumar13:05:51

(map-indexed #(hash-map :index %1 :item %2) [1 2 3])

jumar14:05:10

=> ({:index 0, :item 1} {:index 1, :item 2} {:index 2, :item 3})

jumar14:05:50

And i think the problem is that the former one is equivalent to calling ({:index 0 :item 1})

isaac_cambron18:05:27

@bojan.matic: reason here is that #() treats its contents as something to call, i.e. what you wrote is the equivalent of (fn [idx val] ({:index idx :item val})), note the extra set of parens. So it's trying to do (your-new-map), which needs an argument. You just mean for the function to return the map itself, which #() won't do

jwm18:05:26

@agi_underground: I recommend spacemacs

jwm18:05:32

just add the clojure layer

jwm18:05:42

it throws in cider and clojure-mode

jwm18:05:56

been using it for months now instead of lighttable

henripal19:05:44

@agi_underground @jwm spacemacs seconded. the file linked in this chapter might also be useful: http://www.braveclojure.com/basic-emacs/

agi_underground21:05:34

i`m again here) Need yours advice, which book about clojure (again uptodate) most useful for beginner, who junior level, and have some knowledge in programming, but don`t know clojure language, and want fast as possible start to code web-app? I already was read "Web development with clojure by Dmitri Sotnikov".

lucaska21:05:01

@agi_underground: I just finished “Clojure for the Brave and True” and thought it was great.

lucaska21:05:51

I bought it, but I think the whole thing is online at http://www.braveclojure.com/

agi_underground21:05:01

@lucaska: you think this book has all about clojure syntax and most general clojure way things?

lucaska21:05:57

Very much so.

lucaska21:05:40

Clojure syntax is pretty simple though, and it goes into the more advanced topics too. Plus it’s a pretty fun book.

agi_underground21:05:56

@lucaska: and i intresting in how march time you spend with reading this book?

lucaska21:05:05

Oh, I dunno. About two weeks, reading a half hour a day? 7-8 hours?

lucaska21:05:16

maybe a little more

lucaska21:05:47

It’s online. Start reading it there, and buy it if you like it.

lucaska21:05:06

I read the first chapter there and then thought it was worth the money.

tom22:05:43

Having trouble picturing this one: Paging through results from a REST API and accumulating the results. For example the api might respond {:data [...] :page 1 :pages-available 5}. Which means we are looking at :data for page 1, and we have 4 more pages to get. On each one all we care about are all the values inside :data. Is this a job for anything lazy? Or loop? Or reducing somehow?

bwstearns22:05:12

@tom, maybe you could feed the first reply into a function that requests all remaining pages and then reduces all the responses to extract the :data info.

bwstearns22:05:25

I suppose you could also do it recursively where the base case is that :page equals pages-available (unless pages-available really means remaining in which case the base case is when remaining == 0)