Fork me on GitHub
#beginners
<
2018-11-30
>
adam00:11:27

(ns myns
  (:require [clojure.java.shell :only [sh]]))

(sh "ls" "-aul")
CompilerException java.lang.RuntimeException: Unable to resolve symbol: sh in this context Any idea why?

adam00:11:47

Changing :only to :refer does work but I don't see why :only is not working as described in the docs.

bronsa00:11:15

:only works with :use, not :require

adam00:11:54

@bronsa aha got it, thanks

Ali Ebadian08:11:53

This is great talk, I thought. so I thought some here would find as useful as I did

JanisOlex09:11:11

hello, good people. Is there some good online resource of "clojure cookbooking", like code snippers, examples of everyday tasks performed by idiomatic clojure... Coz one is to know clojure syntax, another thing is to learn actual libraries, and third - know how to bind them togeather... like classical REST api client/server impls, drawing something on screen, making network calls, making data transformations, sound, video and zillion of other nice cool things people do every day

jaihindhreddy-duplicate11:11:06

As far as libraries are concerned, is a good one.

JanisOlex09:11:38

I am asking, coz myself not so long ago learned kotlin, and then soon become "expert" (local) on that, and I noticed, that new people try to write kotlin but using their own language idioms (usually Java), and from my point of view, their code look dirty and silly, which means - most likely my beginner clojure looks as silly

cklaou09:11:27

@olekss.janis Sounds that you're looking for sth like clojure cookbook: https://github.com/clojure-cookbook/clojure-cookbook

👍 4
JanisOlex09:11:49

ahh really, and it's free 🙂 Niice downloaded THanks

sova-soars-the-sora15:11:53

Let's say I have a thread that starts with one post, and can take comments

sova-soars-the-sora15:11:04

I'd like to: store all the comments &

sova-soars-the-sora15:11:43

recursively render the parent->(comment->8<-comment)s

sova-soars-the-sora15:11:03

so I'm thinking for each comment level I can just create a new [:li ""] element...

sova-soars-the-sora15:11:18

I want to store my data not like a comment tree, but by reference. :post_id Xxxx, :parent_id Yyyy, :child_id Zzzz so there's flexibility in how I choose to render them

sova-soars-the-sora15:11:35

so my real question...

sova-soars-the-sora15:11:54

if I have an atom that looks like (atom { :posts [{:pid 555 :cid 777 :this_id 657} {:p 9 :c 8 :tid 7} {:p 12 :c 16 :d 82} {post 4 ...} { post 5} ...]} how can I functionally render the page component that holds a parent and all its child components?

sova-soars-the-sora15:11:25

>
>>
>>>                                        (demonstration of nested comments,
>>>                                         or happy-lil portrait-orientation trees)
>
>>
>>>
>
>>

potetm15:11:56

Anyone who’s interested in learning some clojure is welcome to join my stream of Advent of Code! It will be M-F @ 12:00 CST. I’ll be starting a day early with https://adventofcode.com/2017/day/5.

sova-soars-the-sora16:11:22

works great! but how do i print out more intricately nested maps with multiple attributes and collections of children?

sova-soars-the-sora17:11:14

Now I want to recursively print something like this... well, make a list for html land..

jaide17:11:00

(defn webhook-api
  [{:keys [path-params]}]
  (if-let [id (str->int (get path-params :id))]
    (if-let [webhook (db/get-webhook {:id (Integer. id)})]
      {:body webhook}
      (error-page))
    (error-page)))

jaide17:11:06

Is there a better way to write that?

dpsutton17:11:47

you could make a single function that takes path-params and returns either {:id ...} or nil and have only one if-let

jaide17:11:20

Oooh that’s a great idea. Then I can reuse it in the other routes that require an id.

dpsutton17:11:42

and in combination with some-> you can only look for the webhook if you have the id, etc