Fork me on GitHub
#beginners
<
2018-12-13
>
jstaab00:12:54

Anyone have any tips on making clojure cooperate with linux jobs? I keep getting an IO error whenever I suspend a job to the background and do anything else. Here's what I'm doing:

~ clj -e '(prn "hi")'
"hi"
~ clj -e '(prn "hi")' &
[1] 1104
clojure: error: Unexpected error: Input/output error

[1]  + 1104 suspended (tty output)  clj -e '(prn "hi")'
➜  ~ jobs
[1]  - suspended (tty output)  clj -e '(prn "hi")'
➜  ~ fg
[1]  - 1104 continued  clj -e '(prn "hi")'
➜  ~ jobs
➜  ~

jstaab00:12:18

I'm hitting enter just after [1] 1104 gets printed. If I don't hit anything, my command successfully runs as in the first two lines.

seancorfield00:12:12

@jstaab That's rlwrap -- use clojure instead of clj if you don't want an interactive REPL.

seancorfield00:12:36

clojure -e '(prn "hi")' & should work just fine.

jstaab01:12:25

ah thanks @seancorfield that explains a lot actually

tessy.maliekkal10:12:15

Do anyone know why assoc is not working inside a doall? Is there any alternative to do the association? (defn assoc-test [art-list] (doall (map-indexed (fn [index art] (assoc art :sl-no (+ index 1) (println art) (assoc-in art-list [index :sl-no] (+ index 1)) (println art)) art-list))) (assoc-test [{:id 1, :name "art1"}, {:id 2, :name "art2"}, {:id 3, :name "art3"}]) Niether assoc nor assoc-in are working.

danieleneal10:12:42

I think the problem is you're returning the result of (println), which is nil. The following should work better:

danieleneal10:12:42

I think the problem is you're returning the result of (println), which is nil. The following should work better:

danieleneal10:12:57

(defn assoc-test [art-list]
   (map-indexed (fn [index art]
                  (assoc art :sl-no (inc index))) art-list))

danieleneal10:12:16

So you'd have been getting an sequence of nil back from the map-indexed call because (println art) was the last form, the one that gets returned.

kamil.skowron12:12:21

absolute beginner questions - I'm following "Brave Clojure" book atm, I created a new app and currently printing I'm a teapot - now when trying to run lein repl I'm getting:

➜  clojure-noob lein repl                                                                       
Exception in thread "main" java.lang.AssertionError: Assert failed: transport-fn, compiling:(/tmp/form-init3783791164885581771.clj:1:73)
	at clojure.lang.Compiler.load(Compiler.java:7526)
        ...

danieleneal12:12:10

@kamil.skowron there was a bug in the latest version of leiningen https://github.com/technomancy/leiningen/issues/2497 - I think for now you can downgrade to 2.8.1 via lein upgrade 2.8.1

manutter5112:12:13

@kamil.skowron Just saw some discussion about that last night, there was a problem with the latest* release of lein. Actually the next-to-latest, because they pushed a fix last night. If you upgrade lein, I think that’ll fix it.

danieleneal12:12:30

ah, they already fixed it?

manutter5112:12:56

I think they did, it’s worth a try, but if not there’s always lein upgrade 2.8.1

manutter5112:12:27

Ah, no, I’m mistaken, the lein maintainer published a workaround, he hasn’t pushed a fix yet.

manutter5112:12:49

Adding `[nrepl "0.5.3"]` to `profiles.clj` will address the issue.

kamil.skowron12:12:29

@manutter51 @danieleneal Thanks guys - it works after downgrading

kamil.skowron12:12:47

shame on google and duck duck go - not indexed just yet

kamil.skowron12:12:56

thanks once again :+1:

masta14:12:04

how one would test things like org.httpkit.server starting and stopping. or even -main function ? 🤔

alexmiller14:12:05

-main is just a function - you can invoke it

masta14:12:26

but how to test it?

rodger.scott14:12:51

You can call the function in a repl linked to your project

alexmiller14:12:00

how do you test any function? invoke it and verify outputs and/or change in external state

ben.borders16:12:11

is overriding clojure core functions ok? for example we have a cache client and want to name the fetching function get for example.

bronsa16:12:37

it won't always work due to inlining and direct linking

bronsa16:12:02

for get it will only work when used in higher order contexts for example

trailcapital16:12:03

Yes, it's fine to do that if you want to. You can exclude the core function from your namespace using (:refer-clojure :exclude [get]) in your ns declaration.

bronsa16:12:25

ah -- sorry I thought you meant overriding as in redefining rather than shadowing

mateus.pimentel.w18:12:32

guys, can someone help me with JSX integration in Reagent?

mateus.pimentel.w18:12:54

i’m actually trying to understand how to compile my JSX into JS and reference it in Clojurescript

seancorfield18:12:00

@mateus.pimentel.w Maybe try #reagent and/or #clojurescript channels? (nice avatar, BTW)

mateus.pimentel.w18:12:01

Ty! @seancorfield

lanejo0119:12:07

Hey friends, I’m trying to think of a function or ways to compose a function that when given a string, produces all prefixes of that string. example. “foobar” => (“f” “fo” “foo” “foob” “fooba” “foobar”).

dpsutton19:12:54

(reductions str "" "foobar")

lanejo0119:12:55

Anybody have any ideas? I think today is a slow day for my brain…

lanejo0119:12:24

thanks @dpsutton

dpsutton19:12:26

does what you want. happy to step through it with you if its unclear. its pretty terse but spot on

lanejo0119:12:41

I had looked at reductions but it didn’t click this afternoon.

jaihindh.reddy19:12:15

Like reduce but gives you a seq. of state at each point.

ahmed1hsn23:12:55

Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: amount in this context, compiling:(/home/maverick/Desktop/clj applied/ch1/money.clj:100:1)

ahmed1hsn23:12:07

Kindly test it and tell me reason for this.

dpsutton23:12:55

it worked for me. are you sure you don't have a typo?

dpsutton23:12:15

however, my editor is telling me that snippet is 62 lines long and i'm guessing you have an error at line 100 not 💯

dpsutton23:12:01

can you tell me what is at line 100 in your editor?