This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-30
Channels
- # admin-announcements (4)
- # alda (49)
- # beginners (42)
- # boot (55)
- # cider (33)
- # cljs-dev (4)
- # cljsjs (3)
- # cljsrn (152)
- # clojure (92)
- # clojure-belgium (3)
- # clojure-brasil (18)
- # clojure-dusseldorf (32)
- # clojure-france (2)
- # clojure-greece (10)
- # clojure-japan (1)
- # clojure-mexico (1)
- # clojure-russia (50)
- # clojure-sg (1)
- # clojure-spain (1)
- # clojure-spec (12)
- # clojurescript (262)
- # core-async (2)
- # cursive (7)
- # datomic (79)
- # emacs (16)
- # euroclojure (2)
- # events (1)
- # hoplon (260)
- # jobs (2)
- # jobs-discuss (1)
- # keechma (7)
- # luminus (8)
- # mount (7)
- # off-topic (3)
- # om (101)
- # onyx (33)
- # re-frame (34)
- # reagent (10)
- # slack-help (4)
what you mean with pragmatic directives
is there any proper documentation somewhere which sequence functions are lazy and which not? will first
, for example, force evaluation of the container ?
@fasiha: StringReader and PushbackReader are plain Java. Clojure just sits on top of that stack.
yes, but if there would be some kind of "rationale" behind it so i can make a reasonable prediction about the behavior, it would help 🙂
Well, common sense applies here. Map is lazy and first only needs the first element (chunked seqs will come in small batches regardless and most are chunked) unless the first element is somehow dependent on the realization of the remainder of the seq.
If you keep the head and don't let it GC'd and continue realizing the seq then you'll hold it in memory.
It's complicated and I expect documented when something you'd expect to not realize an entire lazy seq is going to.
well, i'm coming from Haskell, so for me "common sense" is not the type of laziness that Clojure uses
so i'm trying to figure out the thought process behind Clojure's implementation of laziness
His various talks discuss it in detail I think, but I can't pull one out of my behind right now.
Transducers are eager.
(Although a transducer can short-circuit a reduction so you could still transduce a lazy infinite sequence if it stopped after a finite number of elements I guess)
But, yeah, chunked lazy sequences are probably the most surprising thing in Clojure.
@seancorfield: Isn't it cool how I still know like 3 things about Clojure after two years of not writing it. 😄 Feels warm and fuzzy.
Good to see you in here again. How's life been treating you?
And where are you these days? (West Coast I gather)
Sorry :)
They say you either love it or hate it.
They say you make better decisions having actually travelled to more than like 4 places too.
I used to stay in SB when I used to do my West Coast fly/drives before I moved out here.
Always stayed at the California Hotel. It was near my tattoo artist.
so whenever I try and write a file with a java FileOutputStream it gives me a FileNotFoundException. But the output stream is supposed to create the file, why is it doing this?
@donyorm: you'll have to share some code to reproduce your problem, otherwise it'll be rather hard to help. also, consider using clojure's file i/o mechanisms as they're generally easier to use.
I'm trying to implement uploading as detailed here: http://www.luminusweb.net/docs/routes.md#handling_file_uploads
i'd try the individual steps on the repl. is it really the output stream that is failing for you? it seems to me that the problem is not really the FileOutputStream class but rather that there is something wrong with the arguments that you pass to it.
also, what exactly is the error message? maybe you want to look at it more closely. do all directories in the file
path exist?
never mind, it isn't working. Here's the actually error message: java.io.FileNotFoundException: <path> (No such file or directory) All the directories in the path exist. I can copy and paste it to the terminal and cd to it
And you're sure that it is not the FileInputStream that poses the problem? Is it possible that your handler is being called before the file and path is created?
I would use spit/slurp but I'm dealing with image files, and they don't work as fell for that (as for as I can tell)
spit uses FileOutputStream as well, so you'll have to figure out what your problem is. you can be pretty sure that the problem is on your end of it, and not on the end of FileOutputStream.
because in the sample code, they're doing something to their output file before handing it to FileOutputStream, likely for a reason.
yeah, they do you the channels in their example code, but I pretty much copied it word for word.
you're either using a relative path or your function is called before the output directory exists. you'll have to figure out why.
ok, it works when I have it go to /tmp rather than my resources folder. Sorry that took so long. I'll look into why it doesn't like my resouces folder
dang, all the trouble and it has something to do with the permissions on my ntfs drive
anyone know the preferred / idiomatic way of mapping or recursing through a list/vector and modifying an item based on it being the last item in that list/vector?
I’m guessing you’d want to use some sort of recursion with a check on (when (not (rest coll)) do-modify) or some such
@mattsfrey: it certainly depends what datatypes you need to support and how large your lists are
@mattsfrey: but butlast
and last
could be quite proper tools for you in some cases, and they might be the easiest to understand.
@mattsfrey: easy with Specter: (transform LAST inc [1 2 3 4])
-> [1 2 3 5]
It's also compositional, e.g. here's how to increment the last odd number in a sequence:
(transform [(filterer odd?) LAST]
inc
[2 1 3 6 9 4 8])
;; => [2 1 3 6 10 4 8]
Is there a more idiomatic way to do this ?
(with-open [rdr ( "/path-to-big-file")]
(let [lseq (line-seq rdr)
a (atom nil)]
(dorun (reset! a (pmap some-operation lseq)))
@a))
I don’t immediately grasp why you need the atom in there at all? Why not just return the result of pmap
?
It returns a lazy sequence, I need it realized. Anyway I am using a reduce after so it will force the realization.
You can realize a lazy sequence with doall
— no need to put it in an atom first. But you’re right, the reduce will also do it.