Fork me on GitHub
#beginners
<
2017-05-31
>
drewverlee01:05:37

i give up, what value would make this true. i thought the answer was nil, but its not considered true so it fails.

(let [x __]
  (and (= (class x) x) x))

noisesmith01:05:03

@drewverlee imagine if you took an iterator, and took a class of a thing, and found the class of the class of the thing, etc.

noisesmith01:05:11

what would be the fixed point where it just repeats?

john04:05:52

does it have to return true?

john04:05:12

or just a truthy value?

noisesmith04:05:29

well, if it has to return true it's unsolvable

noisesmith04:05:41

I think I recognize it as a koan

john04:05:49

unsolvable, because x would have to be true

john04:05:55

which it isn't

noisesmith04:05:55

if the and wasn't there, nil would work

noisesmith04:05:06

well, class of true isn't true

noisesmith04:05:12

it's Boolean

Jon06:05:29

how to release code to Clojars if I don't use Boot or Lein? I mean no JVM..

Jon06:05:23

After migrating to shadow-cljs I found my build.boot already unnecessary except for releasing package.

matan08:05:30

@ghadi thanks, but I don't see how this ties to relying on one map initialization key while initializing another

ghadi14:05:56

matan: your example code had no dependencies between key-values

matan08:05:01

I was thinking more along the lines of writing a macro, unless some pattern helps with that specific concern

matan08:05:14

Here's one failed shot at such a macro by the way:

gmercer08:05:17

@drewverlee

(if (let [x java.lang.Class] (and (= (class x) x) x)) "hello" "goodbye")

gmercer09:05:18

crowd groans

manu10:05:32

Hi all! I'm developing a mobile app with re-natal. I need to draw a curved line chart, (and maybe animate it). what is the best API to do it? I saw d3 and ART, but d3 is most for the web.. I alsodiscovered Victory https://formidable.com/open-source/victory/docs/native and React-native-Chart https://github.com/tomauty/react-native-chart. What do you think? thanks 🙂

drewverlee13:05:07

@gmercer Thanks. I tried class and i thought i tried java.lang.Class to, i must have done something else though.

drewverlee13:05:20

@noisesmith thanks for the hint :0

hansen-pansen13:05:03

Hello dear channel!

hansen-pansen13:05:12

I'd like to ask a question on ztellman's wonderful manifold: I have trouble to bring manifold deferreds and streams together to perform HTTP requests ins parallel.

dominicm17:05:13

hansen-pansen: what have you tried?

alexsays21:05:24

Hey everyone, I'm trying to understand how lazy evaluation works in Clojure. One thing I've noticed from playing around with the repl is the way in which lazy lists work, for example in Haskell take 10000 $ repeat "foo" will pass the unevaluated values to take and it would be the take function which evaluates the list as it requires. However, (take 10000 (repeat "foo")) requires an initial startup time where repeat is initially lazy but then appears to be evaluated hastily evaluated by take. My thinking on that is that either: 1. Take evaluates the tail first which means (take x (...)) must evaluate to x before returning 2. Repeat does not pass the lazy list to take but instead returns a list of length x 3. This is something to do with the repl and ghci evaluates expressions lazily whilst the clojure repl doesn't

ghadi21:05:13

@alexsays There is no lazy evaluation in Clojure.

dpsutton21:05:26

> Repeat does not pass the lazy list to take but instead returns a list of length x I'm not sure I understand. (repeat "foo") knows how many (`x`) elements take wants before take is evaluated?

ghadi21:05:35

Only lazily realized lists. evaluation in clojure is always strict/eager, unlike haskell

ghadi21:05:18

(seq (range 0 10))

ghadi21:05:37

^ that immediately gives you an object (a seq/list) that happens to have a lazy tail

ghadi21:05:24

The REPL in haskell confuses things a bit because you have evaluate stuff to print it meaninfully, right?

alexsays21:05:34

Ah ok, so http://www.braveclojure.com/core-functions-in-depth/#Infinite_Sequences_ is more just talking about the nature of lists rather than anything specific to clojure?

ghadi21:05:01

But the easiest way to think about it is: laziness in clojure specifically refers to lazy sequences

dpsutton21:05:16

@alexsays what in that chapter contradicts what ghadi has said?

dpsutton22:05:06

it's talking about lazy sequences

dpsutton22:05:08

> However, Clojure comes with a few functions to create infinite sequences.

noisesmith22:05:56

@alexsays repeat doesn’t realize anything, and take only parameterizes how many items will be returned, it’s the printing that realizes if anything (in a repl context at least)

alexsays22:05:18

Don't think any of it directly contradicts. It could be that I'm coming at from the concept of everything being lazy > A lazy seq is a seq whose members aren’t computed until you try to access them To me that indicates that for a list of xs, x won't be evaluated until that element is accessed.

noisesmith22:05:32

@alexsays there’s a crucial bug in nrepl here - nrepl isn’t lazy, and if you call (take 1000 x) all 1000 elements are realized before any are printed

noisesmith22:05:51

this is an nrepl bug, in a real direct clojure repl the items print as they are realized

noisesmith22:05:13

> To me that indicates that for a list of xs, x won’t be evaluated until that element is accessed. remember that printing accesses the items

dpsutton22:05:20

the chapter has a good book of exactly that: (repeatedly (fn [] (rand-int 10))) that function is not computed until the element is accessed

ghadi22:05:40

to be clear -- the call to repeatedly is made

ghadi22:05:17

the data structure that repeatedly returns might not be fully realized

ghadi22:05:40

that is the major difference between clojure and haskell (I think).

ghadi22:05:59

strict (clojure) non-strict (haskell)

alexsays22:05:08

@ghadi the ghc repl is just a monad at its most basic level that's passed a stream of expressions that it lazily evaluates.

dpsutton22:05:22

ah super clear

noisesmith22:05:47

we have exactly one lazy type: clojure.lang.LazySeq - we don’t have lazy evaluation

ghadi22:05:55

^^ what noisesmith said

ghadi22:05:04

"Clojure has a helpful function that can build concrete datastructures lazily."

alexsays22:05:23

So it's not really any strangeness is execution order but more to do with the fact that there's only a small number of data structures which are lazy

ghadi22:05:36

high five everybody

alexsays22:05:09

Is it worth tending to not think about the lazy structures - and assume that when the time comes to use them I'll know - or are they considered an important part of the language?

alexsays22:05:36

Thinking of my experience with scala where LazySeq is only really used in a few edge cases

noisesmith22:05:01

the lazy structures are pretty ubiquitous: map, filter, remove, take, drop, concat

noisesmith22:05:10

(for just a few very common examples)

noisesmith22:05:03

though now most of them have non-lazy transducer variations too

dpsutton22:05:44

> So it's not really any strangeness is execution order but more to do with the fact that there's only a small number of data structures which are lazy there was confusion about this just a second ago

(let [will-throw (try (map risky-function collection) (catch Throwable nil))]
   (reduce rfunc [] will-throw)
and why the exception was not caught

alexsays22:05:25

I've read a little bit on from that chapter and played around a bit. Think I've got my head around it; thanks for the help guys