Fork me on GitHub
#beginners
<
2017-06-08
>
billbarnhill00:06:58

Vaadin. Turns out though that my problem was an out of date JDK on this machine. Horribly out of date. Updated it, and now fn-fx tests pass, so likely will try that.

billbarnhill00:06:21

Likely still try out Vaadin though

billbarnhill00:06:58

But won't be able to use for this project...has to be a desktop app (not my requirement, got handed to me)

vitruvia00:06:13

is there an alternative to (reduced x) if I want to end a reduce early?

noisesmith00:06:30

that’s the one way to do it

noisesmith00:06:40

other than something crazy like throwing an exception

noisesmith00:06:05

that reduced is returned in the context of your chained preds’ input, the reduce is operating on the functions that you are composing

noisesmith00:06:45

the reduce always completes - it returns a function - then that function has another function inside that returns (reduced nil) when you call it

noisesmith00:06:02

but reduce isn’t consuming that reduced value, so it doesn’t prevent the propagation

vitruvia00:06:15

so there is no way to stop the propagation?

vitruvia00:06:36

because this course hasn't talked about throwing exceptions yet and I probably should stop this another way

noisesmith00:06:55

you can check for reduced inside you fn x and stop if the previous step returned a reduced

noisesmith00:06:00

or just use nil and check for that

vitruvia00:06:26

I guess I'm overcomplicating it

noisesmith00:06:20

maybe you meant for the reduce to be inside the function you return

noisesmith00:06:29

rather than using the reduce to create the function you return?

vitruvia00:06:04

I had meant to use reduce to make the function

vitruvia00:06:12

I didn't even think about this other possibility

vitruvia00:06:27

I think I tried doing something with (reduce and (...)) but it didn't let me

rgdelato03:06:35

Hello there! Does Clojure have a shorthand way to bundle a bunch of defs into a map? I'm currently doing:

(let [[first last email amount] (string/split % #",")]
  {:first first :last last :email email :amount amount}
...and I was wondering if there's kind of an inverse of the :keys destructuring form where I can do something like (vals->map first last email amount)

seancorfield03:06:56

(zipmap [:first :last :email :amount] (clojure.string/split "Sean,Corfield,[email protected],100.00" #","))
=>
{:amount "100.00", 
 :email "", 
 :first "Sean", 
 :last "Corfield"} 

john03:06:35

(assoc *1 :amount "110.00")

rgdelato03:06:46

@seancorfield thank you! that works

qle-guen06:06:45

hello comrades, I'm learning macros, I want to concat things somehow like this: (concat ': 'attr '-get-width)

qle-guen06:06:21

such as (macro win) => (:win-get-width)

qle-guen06:06:29

is this possible?

seancorfield06:06:53

@qle-guen A good rule of thumb with macros is to write a function that does almost what you want first, then write a macro that wraps that function.

seancorfield06:06:41

In this case, if you have a function that accepts a symbol and produces the keyword you want, then a macro is just a simple syntactic wrapper around that.

seancorfield06:06:59

(and pretty much the "first rule of macros" is "you don't need macros")

qle-guen06:06:16

@seancorfield thanks but that doesn't really answer my question. Does the function concat exists in this context? Or am I just designing things wrong?

qle-guen06:06:05

I just got a bunch of *-width keywords and that'd make my code clearer

seancorfield07:06:05

concat lazily joins together two sequences.

seancorfield07:06:31

I think you probably want str to join strings together and then keyword to convert the result into a keyword?

seancorfield07:06:27

(keyword (str attr "-width")) like that?

qle-guen07:06:21

ok I'll try that, thanks

qle-guen08:06:33

what is ^ in ^:dynamic?

tap08:06:01

^ is the metadata marker

tap08:06:26

This blog does a great job summarize usages of clojure’s non-alphabetical characters. You might find it useful https://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/

qle-guen08:06:00

@tap awesome, thanks

qle-guen10:06:56

how can I clean the contents of ns-interns?

sb11:06:55

Hi, I would like to save png image (clojure) server-side from base64 encoded string, could you help me? I tried a several method, and something bad.

pkova12:06:07

that'll work

sb12:06:27

@pkova thanks I test it now!

sb12:06:57

I got this message. I don’t know why.

pkova12:06:19

sb: You've got too many braces in your require

pkova12:06:24

it should be like this

pkova12:06:41

`(ns base64encode.core (:require [clojure.data.codec.base64 :as b64] [http://clojure.java.io :as io]))`

pkova12:06:23

(:require [dep1] [dep2])

pkova12:06:38

not (:require [[dep1] [dep2]])

sb12:06:16

Thanks!!!

sb12:06:41

pkova I don’t know.. maybe I tried to fix that too many times.. and I can’t see what is the problem. Could you check once more what is the problem?

sb12:06:21

(def png "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABCgAAADICAYAAAAqY9BtAAA... ....mZmZmZmUWeAwozMzMzMzMzizwHFGZmZmZmZmYWeQ4ozMzMzMzMzCzyHFCYmZmZmZmZWeQ5oDAzMzMzMzOzyPv/tsxWdwyykUUAAAAASUVORK5CYII=")
(with-open [in (java.io.ByteArrayInputStream. (.getBytes png "UTF-8"))
            out (io/output-stream "out.png")]
           (b64/decoding-transfer in out)) 

sb12:06:58

Maybe do I need to use just from the iV…. part?

sb12:06:40

Sorry, works fine! Thanks again!!

sb12:06:47

👍👍👍👍👍

sb12:06:59

big like.. I lost with that 3 hour today…

nmax14:06:34

Hi, what should I use instead of constructors in Clojure?

Alex Miller (Clojure team)14:06:19

data literals (or functions)

nmax14:06:45

ok, thx!

fabrao17:06:13

Hello all, how is the way to destructing this?

{"Link_EMBRATEL"
           {:localidade :ITA, :icmp {:jitter 0.89, :perda 0, :latencia 23.0}}}

fabrao17:06:00

first element to second

donaldball17:06:28

What value are you looking for?

fabrao17:06:17

the first one

gonewest81817:06:04

(let [{e "Link_EMBRATEL"} a
      {localidade :localidade icmp :icmp} e
      {jitter :jitter perda :perda latencia :latencia} icmp]
  ;; ...

gonewest81817:06:29

where a is (def a {"Link_EMBRATEL" ...})

Petrus Theron18:06:29

How do I make environment variables more convenient? Having to type source some-script.sh with a number of export statements before running my app for local dev is a pain. Using environ, I was under the impression that I could write to .boot-env with a map of EDN key-values and it would be loaded at runtime, but (env :my-key) doesn't seem to work. Am I doing something wrong, or is there a way to leverage environ in a different way?

dominicm21:06:40

petrus: alias launch='source ./vars.sh && lein repl but this in your .bashrc or similar, and you can use launch to start the project?

weavejester23:06:21

@petrus .boot-env is an internal file. You can add environment variables programmatically in development by adding them as a map to the environ task.

weavejester23:06:31

There’s an example in the README