#clojure logs

2015-07-09

00:17shiranaihitoelvis4526: there are only stupid answers :)
00:19currentoorHas anyone built a datomic backed application and deployed to heroku?
00:26currentoorI was wondering what's the right way to deploy a datomic backed app for a beginner?
00:31namrahm there's something i don't understand with atoms: http://pastebin.com/iGYyF7M9
00:31namrait'll throw a nullpointer exception at the places (not (nil? kh @heartbeat-counter)) and (< (kh @heartbeat-counter))
00:31namraand i don't understand why
00:32namrasomeone an idea?
01:29andyf_namra: still there?
02:03namraclojuredocs.org down?
02:14kwladykawhen should i use sets?
02:14kwladykaif i need unique values it mean i should sets or not necessary?
02:26namrakwladyka: "Sets are collections of unique values.
02:26namra"
02:26namraso yea if you want a collection with no duplicates
02:27namra(doc #{})
02:27clojurebot#error {\n :cause "clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Symbol"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassCastException: clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_FILE:0:0)"\n :at [clojure.lang.Compiler macroexpand1 "Compiler.java" 6644]}\n {:type java.lang.ClassCastException\n :message "clojure.lang.PersistentHas
02:27namra(doc #)
02:27clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
02:27namra(doc sorted-set)
02:27clojurebot"([& keys]); Returns a new sorted set with supplied keys. Any equal keys are handled as if by repeated uses of conj."
02:27namra(doc set)
02:27clojurebot"([coll]); Returns a set of the distinct elements of coll."
02:30kwladykado you have idea what will be the best way to save coordinates on 2-dimension board with description what is there? For example #{[[1 1 :king][1 3 :king][3 2 :rookie] [[1 1 :king][2 3 :rookie][3 1 :king]]} <- but i am not satisfy with that... i need something in more order like... i could read give-me-all-positions-with-order-and-what-is-there
02:34kwladykain other word: i am looking the best way to write/read coordinates on 2-dimension board to later draw this board
02:36aztakkwladyka: hehe, I'm doing something similar to render a maze :)
02:36aztakI actually use a hash where keys are the coordinates:
02:37aztak{[0 0] {:some-content 123}, [0 1] {:another-content 345}}
02:37aztakLookup is then simply ([0 0] map-ref)
02:38aztakNot sure if it's the best approach - another alternative would be nested vectors (a 2-d array).
02:38kwladykammm now it looks like obviously solution :)
02:38kwladykaaztak, thx
02:41kwladykaaztak, did you miss #? {[0 0] {:some-content 123}, [0 1] {:another-content 345} or #{[0 0] {:some-content 123}, [0 1] {:another-content 345} ?
02:42kwladykahow do you solve only one thing can be in one place?
02:43aztakNo - '#{}' is a Set, right? I have a Hashtable '{:key1 value :key2 value}'
02:43aztakkwladyka: I don't - it isn't needed for my maze hack :/
02:44aztak(but unique coordinates is enforced since the coordinates [x y] is the key of the Hashtable)
02:46kwladykaaztak, i think i need something like #{{[1 1] :king, [1 3] :king, [3 2] :rookie} {[3 3] :king, [1 3] :king, [1 2] :rookie} {[3 3] :king, [1 3] :king, [2 1] :rookie} {[2 3] :rookie, [1 1] :king, [3 1] :king}}
02:47kwladykayeah but i have to remeber all possible unique configurations of figures on the board
02:47kwladykaso i think i should use sets of maps :)
02:50kwladyka*rookie -> rook :)
03:40celwellHi, is there a prettier way to write this, since it's using the 'o' so repetively:
03:40celwell(defn valid-price?
03:40celwell "Is the stated 'total_price' accurate?"
03:40celwell [db-conn o]
03:40celwell (= (:total_price o)
03:40celwell (calculate-cost db-conn
03:40celwell (:gas_type o)
03:40celwell (:gallons o)
03:40celwell (:time-in-minutes o)
03:40celwell (:coupon_code o)
03:40celwell (:vehicle_id o)
03:40celwell (:user_id o)
03:40celwell (:referral_gallons_used o))))
03:40justin_smithcelwell: don't do that
03:41celwelloops, should have used a gist I guess
03:42celwellHere is the code: https://gist.github.com/celwell/08aa26dade2550d92631
03:42justin_smithcelwell: (apply calculate-cost db-conn ((juxt :gas_type :gallons :time-in-minutes :coupon_code :vehicle_id :user_id :referral_gallons_used) o))
03:43justin_smithcelwell: alternately (apply calculate-cost db-conn (map o [:gas_type :gallons :time-in-minutes :coupon_code :vehicle_id :user_id :referral_gallons_used]))
03:44justin_smithit might also make sense to define calculate-cost to take a hash-map as an arg
03:44celwellHmm... thanks. How would you personally do it?
03:44celwellthe last suggestion?
03:44justin_smithI think so, unless I had a strong case not to use a hash, I usually use a hash-map arg if there are that many individual parameters
03:45justin_smiththe calls are just more readable that way usually
03:45Bronsadon't forget about destucturing
03:46justin_smithyeah, I'd be destructuring on the impl side :)
03:46celwellsorry, how would destructing work?
03:47justin_smith(defn calculate-cost [db {:keys [gas_type gallons time-in-minutes ...]}] ...)
03:47justin_smiththen you call (calculate-cost db o)
03:47celwellinteresting route to go
03:48justin_smithI'd do it that way if the args usually all come from the same place
03:48justin_smithI'd likely even do it if they didn't for readability's sake...
05:08expezIf you give me a new file path, how can I construct a matching ns name? Is this even possible without asking boot or leiningen about the project layout?
05:16expezWhat I'm doing now is given a path I list all the dirs on classpath and use those to drop a prefix from the path, that should leave me with a relative path which I can turn into a ns. If there's more than one hit I grab the shortest path :/
05:28Thoocei1Hello. I have a rather minor question regarding reader conditionals. It seems to me that clojure used to use vector literals for the cases where there is key-value pairs the order of which does matter. Reader conditionals, though, use list literal. Is there any meaning to it or is it just a random choice?
06:16fikusz(type (int 10)) gives me java.lang.Integer: how can I get a primitive int type?
06:28PupenoDoes anybody have a recommendation on libraries to do http requests (get, posts, cookies) and parsing the resulting html?
06:30arrdem$mail andyf great that sorting function worked perfectly and is live as of now. bug fixed.
06:30lazybotMessage saved.
06:32dstocktonPupeno: clj-http and enlive?
06:33PupenoThanks.
06:45PupenoDo you use envile for parsing HTML? it looks like a templating engine.
06:47tdammersit's both, in a way
06:47tdammersalthough that might not be immediately obvious from skimming the documentation
07:55PupenoIs there a more idiomatic way to do two assoc-ins other than nesting them?
08:07aztakPupeno: assoc supports multiple key-values
08:07aztak,(def a-map {:foo "bar"})
08:07clojurebot#'sandbox/a-map
08:07Pupenoaztak: but I'm not using assoc, I'm using assoc-in.
08:08aztak,(assoc a-map :zip "zap" :zap "zip")
08:08clojurebot{:foo "bar", :zip "zap", :zap "zip"}
08:08aztakah :)
08:08aztakread that too fast, sorry :)
08:08Pupenonp
08:27hyPiRionPupeno: Depends on the keys you pass to assoc-in. (-> (assoc-in m [:foo :bar] "bar") (assoc-in [:foo :baz] "baz")) = (update-in m [:foo] (assoc :bar "bar" :baz "baz)) = (update m :foo (assoc ...))
08:28hyPiRionThough I tend to thrush my update-ins sometimes without issues, and I don't think it's unidiomatic.
08:38aztakhyPiRion: ah, yeah - threading makes the assoc-in slightly less verbose ... I tried using reduce and a vector of vectors - but that's too obfuscated imo.
08:40aztaksomething like (multi-assoc-in m [:foo :baz "bar"] [:foo :bar "baz"])
08:49crocketHow do I traverse a list recursively for side effects in a clojure macro?
08:49crocketclojure.walk.walk doesn't seem to fit my need.
08:50crocketI want to collect the list of symbols in a list and return it.
09:10snowellcrocket: Do you mean get only the values that are symbols?
09:10snowellEither way it doesn't sound like a side effect
09:12justin_smithcrocket: in a list, or a nested list?
09:14crocket(get-symbols (+ 1 2 3 (- 1 2 3))) == ("+" "-")
09:14crocketI want to write get-symbols macro)
09:15crocketjustin_smith, snowell ^^
09:15snowell,(filter symbol? (flatten '(+ 1 2 3 (- 1 2 3))))
09:15clojurebot(+ -)
09:15justin_smith,(map name (filter symbol (tree-seq '(+ 1 2 3 (- 1 2 3)))))
09:15clojurebot#error {\n :cause "Wrong number of args (1) passed to: core/tree-seq"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/tree-seq"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval49 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Co...
09:15justin_smith:P
09:16crocket,(map name (filter symbol? (tree-seq '(+ 1 2 3 (- 1 2 3)))))
09:16clojurebot#error {\n :cause "Wrong number of args (1) passed to: core/tree-seq"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/tree-seq"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval73 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Co...
09:16justin_smith,(map name (filter symbol (tree-seq seq seq '(+ 1 2 3 (- 1 2 3)))))
09:16clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.String>
09:16justin_smith,(map name (filter symbol? (tree-seq seq seq '(+ 1 2 3 (- 1 2 3)))))
09:16clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>
09:16snowell(apply str (filter symbol? (flatten '(+ 1 2 3 (- 1 2 3)))))
09:16justin_smithugh
09:17snowell,(apply str (filter symbol? (flatten '(+ 1 2 3 (- 1 2 3)))))
09:17clojurebot"+-"
09:17crocketClojure compiler is rejecting your errors.
09:17snowellgrr
09:17snowell,(map str (filter symbol? (flatten '(+ 1 2 3 (- 1 2 3)))))
09:17clojurebot("+" "-")
09:17crocket,(doc flatten)
09:17clojurebot"([x]); Takes any nested combination of sequential things (lists, vectors, etc.) and returns their contents as a single, flat sequence. (flatten nil) returns an empty sequence."
09:17justin_smith,(map name (filter symbol? (tree-seq seq? seq '(+ 1 2 3 (- 1 2 3)))))
09:17clojurebot("+" "-")
09:18crocket,(doc tree-seq)
09:18clojurebot"([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree."
09:18snowelljustin_smith's answer is probably better or more elegant. Usually is :D
09:18crocketI think snowell's solution is more concise.
09:19crocket,(filter symbol? (tree-seq seq? seq'(+ 1 2 3 (- 1 2 3))))
09:19clojurebot#error {\n :cause "Unable to resolve symbol: seq' in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: seq' in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: seq' in this co...
09:19crocket,(filter symbol? (tree-seq seq? seq'(+ 1 2 3 (- 1 2 3)))))
09:19clojurebot#error {\n :cause "Unable to resolve symbol: seq' in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: seq' in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: seq' in this co...
09:20crocket,(filter symbol? (tree-seq seq? seq '(+ 1 2 3 (- 1 2 3))))
09:20clojurebot(+ -)
09:20crocket,(doc flatten)
09:20clojurebot"([x]); Takes any nested combination of sequential things (lists, vectors, etc.) and returns their contents as a single, flat sequence. (flatten nil) returns an empty sequence."
09:20musty:(
09:20crocket,(flatten (+ 1 2 3 (- 4 5 6 (+ 7 8 9) 10 11 12)))
09:20clojurebot()
09:20crocket,(flatten (+ 1 2 3 (- 4 5 6 10 11 12)))\
09:20clojurebot()
09:20snowellcrocket: You have to quote the list
09:21justin_smith,(flatten {:a 0 :b [1 2 3]})
09:21clojurebot()
09:21crocket,(flatten '(+ 1 2 3 (- 4 5 6 10 11 12)))
09:21clojurebot(+ 1 2 3 - ...)
09:21crocket,(flatten '(+ 1 2 3 (- 4 5 6 )))
09:21clojurebot(+ 1 2 3 - ...)
09:21justin_smith,(flatten #{[:a :b :c] [[:d :e] :f]})
09:21clojurebot()
09:22crocket,(flatten '#{[:a :b :c] [[:d :e] :f]})
09:22clojurebot()
09:22crocketIs set a sequence?
09:22justin_smith,(seq? #{:a})
09:22clojurebotfalse
09:22justin_smith,(coll? #{:a})
09:22clojurebottrue
09:22crocket,(seq? [1 2 3])
09:22clojurebotfalse
09:23crocket(seq? '(1 2 3))
09:23crocket,(seq? '(1 2 3))
09:23clojurebottrue
09:24crocket,(list? '(1 2 3))
09:24clojurebottrue
09:24justin_smith,(list? (list 1 2 3))
09:24clojurebottrue
09:24crocket,(coll? '#{1 2 3})
09:24clojurebottrue
09:24justin_smithyou don't need the ' there
09:24crocketI think clojure will be complemented well by pixie.
09:25crocketclojure is a lot more elegant than java, javascript, python, C, and C++.
09:25tdammersthat's not a very high standard to compare yourself with :x
09:26crocketThose are the languages I learned in the past,
09:26crocketI can't compare clojure with languages I haven't learned.
09:26tdammersobviously :D
09:26crocketI retired as a commercial programmer, and now I learn at home.
09:27tdammerscool
09:27crocketMost commercial programming environments are degrading.
09:27tdammerstell me about it
09:27crocketMost companies prevent you from learning.
09:27tdammersI'm lucky enough to have found one where at least the technical side of things is pretty awesome, and we can mostly ignore the business shenanigans
09:28crockettdammers, Which company do you work for?
09:28tdammerstiny one in the netherlands
09:28crocketIs it a lab?
09:28tdammersnope
09:28crocketIt's typically a corporate lab.
09:28tdammerswell, not really... we're not sure yet
09:28crocketCan you tell me the name? I want to see the website.
09:28tdammerswe don't really have a website
09:29crocketok
09:29tdammersworking on that
09:29crocketWhat do you do?
09:29crocketWhat does the company do?
09:29tdammersgovernment-related stuff
09:29tdammerswe're operating on the edge between government IT and the corporate world
09:29crocketAnyway, good luck with maintaining a high degree of autonomy once your company grows beyond 20 people.
09:29tdammersoh, the parent company is larger than that
09:30vas_Hi everyone..
09:30tdammersbut our team is currently 5 people
09:30vas_What does "Don't know how to create ISeq from: java.lang.Long" usually mean o_O
09:30tdammerswith a bit of commercial support from "outside"
09:30tdammers(in the form of marketing, sales, profitability research, etc.)
09:30justin_smithvas_: it means numbers are not sequential collections
09:30crocketA good thing about learning at home is you get to learn and work on things as you see fit.
09:30tdammers(and also money)
09:30justin_smithvas_: eg. ##(first 1)
09:30lazybotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long
09:30tdammerscrocket: absolutely, and clojure is a wonderful playground for these things
09:31crocketNo company would pay me for what I want to do for now.
09:31tdammersme neither, but this is close enough for now
09:32crocketI plan to learn several languages and AIs.
09:32vas_justin_smith: Oh thank you that is very clear.
09:32crocketIt's going to take 3-4 years to finish learning and start working on AIs.
09:32crocketHowever, the learning doesn't stop there.
09:32tdammersnah, I wouldn't look at it that way
09:32crocketIt will take about 3-4 years to start working on AIs.
09:32tdammersyou never finish learning, you just do things as well as you can, and you learn along the way
09:33crockettdammers, I was about to say that I never stop learning.
09:33tdammersand no, I don't think you need to spend 3 years before you can write a simple AI
09:33copycathow does clojure compare with racket?
09:33crockettdammers, The kind of AIs that I want to write takes years of learning.
09:33crockettdammers, I'm learning it from a mentor.
09:33tdammersI believe you could probably learn enough clojure to write something like a state transition diagram based AI within a month or so
09:34crockettdammers, His AI design requires knowledge of semiotics, turing ordinal, and so on...
09:34tdammersjust do a bunch of simple ones first, and you'll stumble upon the relevant language features
09:34tdammersah, but then the bottleneck is more in the realm of grokking the theory
09:34tdammersnot so much implementing it in a programming language
09:35crockettdammers, Right now, I don't even know the relevent theories.
09:35tdammersexactly
09:35tdammersI bet once you do, and have gotten your feet wet a bit, the implementation part isn't going to be the biggest problem
09:35crocketMeanwhile, I want to build some useful web services that I use personally.
09:35crocketI also want to write some simple CLI apps in clojure-like pixie.
09:36crocketI'd definitely use clojure for any non-trivial apps...
09:39crocketcopycat, You can compare runtime performance characteristics of clojure and racket.
09:39crocketRacket runtime doesn't require a lot of RAM, and it starts up fast.
09:39crocketBut, after loading, racket is slower than clojure.
09:39copycati don't think i'm programming at a level where i need to care about the run time performance
09:39crocketRuntime performance matters if you want to write simple CLI apps.
09:40crocketclojure doesn't fit small CLI apps.
09:40tdammers^
09:40crocketFor any CLI app that needs to be executed repeatedly, startup time needs to be small.
09:40copycatwhat are examples of CLI apps?
09:40r4vithere's also hy which allows you to use the python interpreter
09:40tdammersexactly. if you want to use it in a script, we're talking milliseconds here
09:40copycati've only made GUIs for fun
09:40crocketcopycat, DDNS clients, ntp clients
09:41tdammersthe DDNS client could be written as a daemon though
09:41copycatto be honest
09:41copycati've never heard of those terms
09:41tdammersthe NTP clients *should* be written as a daemon, even, so that you can nudge instead of jump
09:41crocketIf you want to run a DDNS client daemon on Raspberry Pi, clojure won't cut it.
09:41copycatlike i said, i'm new to the world of software
09:41copycatGUIs are all i'm familiar with
09:41tdammerswell, JVM in general on a Pi sounds like a bad idea to me
09:42crocketIf you want to run daemons on OpenWrt and RaspBerry Pi, clojure will not make it.
09:42copycatwhich is why racket was so good for me, all i had to do was download an installer and everything worked out of the box on windows
09:42copycatwith a simple easy-to-use ide
09:42crocketWhile Racket is a good language, it has multiple languages.
09:42tdammersidk, the IDE and how everything assumes that you want to use it somewhat turned me away from racket
09:43tdammersnot my style at all
09:43crocketAnd, clojure has one style.
09:43crocketone langauge, one stgyle
09:43copycati guess it's aimed for easing newbies into software development
09:43crockettdammers, You can use emacs istead of DrRacket.
09:44tdammerscrocket: more of a vim man myself
09:44crocketvim works well on terminals.
09:44crocketemacs doesn't.
09:44copycatwhat programs did you guys work on when you started learning programming?
09:44copycatCLI apps?
09:44tdammersMS-DOS 4 batch scripts
09:44copycati thought most people begin by creating GUIs and games
09:45zimabluefor me - yes, tiny c++ programs that calculated the movements of pendulums at uni, this was about 6 years ago
09:45zimablueI think the next generation will probably be straight in with guis and javascript
09:46tdammersthe current generation already is
09:46tdammersmobile apps and all that
09:47digiorgic++ data structures in the university
09:52copycati have a couple of newbie questions
09:54copycati know this sounds dumb, but what's so good about a question about being hosted on the jvm?
09:54copycatthe website doesn't offer much in the way of information
09:54justin_smithcopycat: existing corporate infrastructure
09:54copycatwhat does that mean in concrete examples?
09:55justin_smithboth in terms of libs that connect to just about anything, and tooling and platforms that larger companies already have set up
09:55tdammersone advantage is that it's easier to sell to management
09:55justin_smithit means that if you need aes encryption, a cross-platform gui, UDP messaging using the OSC protocol etc. then the libs all exist
09:55tdammersyou don't need to hire new IT staff, you don't even have to train them
09:55tdammersthe deployment procedure is pretty much the same - "here's a jar, do your thing"
09:56justin_smithit also means that if you need to deploy to servers, the tooling for deploying for the jvm is already out there
09:56justin_smithexactly
09:56justin_smithit also means, in terms of optimizing the resulting code, we can just re-use the runtime optimizations of the jvm
09:56tdammersit also means that if you have one team in the organisation doing interesting stuff with clojure, while the rest does boring business CRUD things in Java, you can still interface with each other pretty seamlessly
09:56copycatcould you elaborate on - the deployment procedure is pretty much the same - "here's a jar, do your thing"
09:56justin_smithinstead of inventing that from scratch
09:57justin_smithcopycat: in order to run a clojure uberjar, all you need is java
09:57justin_smiththat's literally the only thing that needs to be installed on the server
09:57tdammersand yes, from the language implementation point of view, it means that you only need to invent the "front-end" part
09:57tdammersit was an important factor in getting clojure the traction any new language needs
09:58tdammersI think that if it hadn't been for the jvm, clojure wouldn't have made it
09:58copycatwhat other things does clojure has going for it?
09:58justin_smithcopycat: compare this to ruby or python, where you need to have the right runtime versions installed for your app, and the right libs, and versions of all your libs that play well together, and these are all exclusive global installations
09:58tdammersnot because other lisps are necessarily better, but because they would have had a more complete set of libraries available
09:58blkcat^ strongly agree. jvm was clojure's trojan horse
09:59justin_smithcopycat: pervasive immutability without having to deep copy all your data
09:59tdammersjustin_smith: that comparison isn't entirely fair though, because clojure is compiled and python isn't
09:59justin_smithtdammers: sure, I am just talking about the relative complexity of setting up a server to host jvm vs. python or ruby apps
09:59tdammersyes
09:59tdammersofc
09:59justin_smithtdammers: lots of unfair comparisons there :) but we have unfair advantages
10:00copycatbeing able to plug in clojure code into enterprise software does sound amazing
10:00copycatof course, i have no idea about both
10:00tdammersbut if you compare it to, say, C, or Haskell, the only difference I can think of is that your jar will work on any host platform unchanged
10:00justin_smithcopycat: yeah, lots of people host clojure on apache tomcat or jboss or wildfly, it just works
10:00copycatbut it does that have that "real world use" that would compell me to learn a language
10:00tdammersbut if you know the platform, the only thing you need for deploying Haskell code is libc and libgmp
10:01justin_smithtdammers: dependency management to set up a server for c or haskell programs that are not statically compiled can be insane
10:01copycathow does one manage a huge clojrue codebase?
10:01justin_smithtdammers: private scope of installation and automatic version resolution without conflicts are not to be lightly dismissed as advantages
10:01tdammersjustin_smith: well, that's why people usually static-link everything except libc and libgmp in haskell ;)
10:01justin_smithtdammers: heh, sure
10:02justin_smithtdammers: but then you still have dependency hell on the dev and build machines
10:02justin_smithtdammers: compare getting someone set up with all the right tool versions to do haskell or c, with getting lein installed
10:02tdammershaskell is pretty straightforward
10:02tdammersC, ugh
10:02justin_smithanother way to put it: think of all the vm images and docker containers that clojure doesn't need :)
10:03justin_smithtdammers: even haskell has cabal hell
10:03tdammersit's an unsolvable problem though
10:03justin_smithtdammers: clojure (with the help of maven) solves it pretty nicely
10:03tdammerseasiest way out is to use fixed versions for everything
10:03justin_smithI mean there are dep conflicts, but in a project, not an OS level
10:04tdammersoh, but Haskell works just the same, as long as you follow common advice and build in a cabal sandbox
10:04justin_smithtdammers: I can switch versions of deps in a project without hosing my .m2
10:04copycatis there a C FFI for clojure?
10:04justin_smithtdammers: switching deps inside a cabal sandbox can hose things, bad
10:05copycati don't see an official link with google search results
10:05justin_smithtdammers: because things are compiled against impl details of the compiled deps
10:05tdammersthat's why it's sandboxed :D
10:05justin_smithtdammers: so you throw it all away and rebuild -- rather than just compiling to interfaces
10:05justin_smiththere's a difference there, is all I am saying
10:05tdammersoh, sure
10:05tdammersbut then, the interfaces tend to be a lot stricter in Haskell
10:06tdammerskind of the point of the whole thin
10:06justin_smithright, but Haskell doesn't compile to interfaces, so that's moot
10:06justin_smithotherwise the previously mentioned problem wouldn't be happening
10:07tdammersbut that reduces the problem to "build times are sometimes longer"
10:07justin_smithcopycat: there are FFI libs for the jvm that clojure can use (and even some clojure bindings), but that's hairy territory, it leads to platform dependent code and can break in lots of ways
10:08copycatjvm libs, ok
10:08copycathow does one manage a huge clojure codebase?
10:08justin_smithtdammers: sure, but compare OCaml, where things compile to the interface, and build times are orders of magnitude better, with the same type strictness
10:09justin_smithcopycat: same as any other language I think, make and use libraries, use git, use unit tests
10:09wasamasacopycat: one simplifies until oblivion
10:09tdammersI'm not extremely familiar with OCaml, but wasn't there something about typeclasses and open universes that makes this a no-go in haskell?
10:09justin_smithcopycat: stuartsierra's component lib is good for dep injection style stuff
10:09copycat"dep injection style stuff"
10:09copycatyou've lost me :(
10:09justin_smithtdammers: yeah, they have different models (ocaml's is more pragmatic, while still being strict like haskell)
10:10copycathow mature is typed clojure?
10:10justin_smithcopycat: "my lib requires a logger, but I'll let the end user decide which logger gets used"
10:10tdammersmy impression is that ocaml has less abstractive power
10:10tdammerscould be wrong though
10:10justin_smithtdammers: yes, it's simpler and less abstract in the type system
10:11tdammersso in a way, part of haskell's problem is that it allows for more holes to be punched into the type firewall (excuse the metaphor)
10:11copycatmind if i ask what you guys use/do at work and for leisure?
10:12copycatprograms and applications
10:12justin_smithtdammers: if OCaml were simply better than haskell more people would be using it - it just makes different (generally more pragmatic) design decisions, while coming from the same language family. But both have strict hindley-milner inferred typing in the generally ml style, and ocaml compiles so much faster its kind of amazing
10:13snowellcopycat: Work = Clojure/Clojurescript, Java, Javascript, groovy currently. Leisure = Clojure :)
10:13tdammersjustin_smith: well, yeah, ocaml is definitely on my bucket list... I'm thinking it might be a good candidate to fill my needs for a high-level language with slightly more predictable performance characteristics
10:14snowellAlmost entirely for web apps, though my company also does some product development
10:14digiorgiWhen i try to run "lein trampoline cljsbuild repl-rhino" i get Exception in thread "main" java.io.FileNotFoundException: Could not locate cljs/repl__init.class or cljs/repl.clj on classpath: , compiling:(cljsbuild/repl/rhino.clj:1:1)
10:14tdammerscopycat: work: clojure, clojurescript, python, JS; projects on the line between gov't and the corporate world. Leisure: go-to languages currently Haskell, C++, C, JS, occasionally Python
10:15justin_smithtdammers: there's a reason the next haskell will be strict http://www.cs.nott.ac.uk/~gmh/appsem-slides/peytonjones.ppt
10:15tdammersoh, I have no doubts about that
10:15justin_smith(that's a presentation by one of the primary authors of haskell, if you don't recognize the name)
10:15tdammersI do
10:16tdammersuncontrolled laziness has always struck me as a blatant oversight in Haskell's design
10:16wasamasajustin_smith: .ppt?
10:17wasamasajustin_smith: seriously?
10:17copycatsnowell: would it be possible to do everything in clojure/clojurescript?
10:18justin_smithwasamasa: it's the format peyton-jones chose, there's a reason to refer to him rather than another author (any other really) on this subject
10:18wasamasadamn these ms researchers
10:18justin_smithwasamasa: and damn ms for having the money to buy all the best researches :)
10:18snowellcopycat: Possible? Maybe. Allowed by management? No way
10:19wasamasajustin_smith: oh, I'm pretty sure he went there on his own
10:19tdammerspffff, "allowed by management"...
10:19wasamasajustin_smith: I just find it slightly ridiculous how he's using comic sans and powerpoint for his slides
10:19justin_smithwasamasa: agreed
10:19snowellcopycat: Lots of this stuff is legacy code/interfaces (gov't work). And the product dev is a giant java codebase :)
10:19tdammersmanagement should allow whatever choices you make, but you should make choices that are good for the business as a whole
10:19wasamasaCOMIC SAAAANS
10:19tdammersoh, the comic sans thing
10:19tdammersI think he does that on purpose
10:19wasamasayes he does
10:20wasamasasomething about the font getting too much hate
10:20snowelltdammers: In contracting, the customer may not always be right, but he does have the money
10:20tdammerssnowell: yes, and if the customer's business case is "please build something that my in-house people can maintain", then "we'll use this language your people have never heard of" is not the right decision
10:21snowelltdammers: Won't stop me from trying ;)
10:21tdammersstill don't see why management needs to be involved
10:21tdammersheh, sure
10:21tdammersbest way IMO is to get to the point where you can afford to sell "NO" to the customers who want such a thing
10:21tdammersand take on only those who are open to whatever tech you pick
10:22tdammersand I think that's something you need to earn, in a way
10:22copycatwould management know if you ported the java codebase to clojure?
10:22snowellcopycat: They'd figure it out once somebody else had to come in to maintain it
10:23copycati guess the bad thing for them is that java programmers are more plentiful?
10:25tdammersfwiw, as painful as that is, for many of these things, java *is* the right tool, somehow
10:26tdammersas programmers, we sometimes forget that technical superiority is just one of many factors
10:26tdammersmy sale manager's daughter being in the same hockey club as your sales manager's daughter is just as important a factor, from a business perspective
10:27tdammersand an expensive IT consulting firm saying "use java, that's what we know" is also a very important factor
10:29copycatcould you expand on the last part?
10:29copycatyou mean the consulting firm will influence management?
10:32mkcopycat: your software needs to be maintainable. If you rely on a consulting firm either a) for present maintenance, or b) as a safety net in case the project goes south, and that firm says "we can't work with that", then you won't want to use that
10:36mkcopycat: you need both social and technical infrastructure (or lack thereof) for certain languages to make sense. If the majority of the programmers you hope to recruit use C#, or if your customers are invested in Microsoft products, you'll end up using C# over Java or Clojure
10:38winkI don't think the "developers already know language X" is a valid point really
10:38copycatmk: how do software shops introduce/integrate new languages into their legacy codebase?
10:38copycatnot start-ups
10:39snowellband-aids and duct tape :)
10:39Frozenlocktdammers: I don't know if it's really 'forgetting', rather than seeing what should be optimized for one's own benefit. For example, suppose I work in an enterprise where everyone is using Excel as databases. Now, if I do what's currently best for the enterprise, it would be to suck it up and also use Excel. However, the value I can bring to the table is greatly reduced if I constantly bang my head on Excel, which should also be
10:39Frozenlockreflected on my salary. I would expect most people to try to set themselves in an environment where they can maximize their productivity, even if for the enterprise at large it can be a net negative.
10:40copycati mean the social process of convincing management/colleagues :)
10:42tdammersFrozenlock: maybe... but my strategy for that is to quietly go find a job where I am more useful and more valued
10:42FrozenlockOf course, but before going through all this trouble, you try to optimize locally.
10:42tdammersyes
10:43tdammersbut they way to get there is to convince the environment that maximizing your productivity is a net gain
10:43FrozenlockThere lies the difficulty :-p
10:44mkcopycat: slowly. If you mean socially, you need buy-in from well-established programmers at that company. They'll have a record of making reasonable decisions. So... you could propose something, but it's not up to you, unless you establish yourself as a top programmer
10:47copycatmk: have you worked in a bigco before?
10:52noncomwhat is the character literal for backslash ?
10:52noncom,\\
10:52clojurebot\\
10:52noncomthis?
10:52clojurebotthis is an outrage!
10:54mkcopycat: like Microsoft or Google? No, but I don't expect the process to be anything but more formal. If you're still curious, you might ask at something like programmers.stackexchange
10:54copycati prefer interactive chats with irc people :)
10:57digiorgiHi i cant start any clojurescript repl, lein trampoline cljsbuild repl-rhino
10:57digiorgior repl-listen, fails
10:58digiorgiwith java.io.FileNotFoundException:
11:06mkdigiorgi: which file is not found?
11:18digiorgi java.io.FileNotFoundException: Could not locate cljs/repl__init.class or cljs/repl.clj on classpath: , compiling:(cljsbuild/repl/listen.clj:1:1)
11:19digiorgimk: or java.io.FileNotFoundException: Could not locate cljs/repl__init.class or cljs/repl.clj on classpath: , compiling:(cljsbuild/repl/rhino.clj:1:1)
11:23chomwitt,(str [\u2620])
11:23clojurebot"[\\☠]"
11:23chomwittis that logical?
11:24chomwitta vector with one character will become string with 3 characters?
11:26hyPiRion,(map (juxt str pr-str) [[1 2 3] ["1" "2" "3"] [\1 \2 \3]])
11:26clojurebot(["[1 2 3]" "[1 2 3]"] ["[\"1\" \"2\" \"3\"]" "[\"1\" \"2\" \"3\"]"] ["[\\1 \\2 \\3]" "[\\1 \\2 \\3]"])
11:27chomwittdidnt get it
11:27hyPiRion,(println ["foo" "bar"])
11:27clojurebot[foo bar]\n
11:28vas_Someone give me a high five I just found this error xD
11:28hyPiRionchomwitt: You'd like to have the property that (= (read-string (pr-str thing)) thing)
11:59{blake}I've been trying to upgrade my lein-ring from 8.13 to 9.6 and I find that when I WAR it up and deploy it (via Wildfly) Wildfly chokes with a Java servlet error. I've had a dependency of [javax.servlet/servlet-api "2.5"] all along so I feel like I need to change that somehow.
12:00justin_smith{blake}: "a java servlet error" isn't very helpful
12:02{blake}Yeah, I know. :-/ It's a pretty expansive error message. I had a wan hope that someone would say "Oh, yeah! I know that 8->9 upgrade problem!"
12:03blkcatpastebin it? :)
12:03{blake}Well, here's what I'm looking at: => Attempting to call unbound fn: #'myapp.servlet/service-method
12:03{blake}I'm thinking that's the problem.
12:04jcrossley3{blake}: wildfly uses version 3 of the servlet spec. i wouldn't think you'd need to make that dep explicit anyway.
12:06{blake}jcrossley3: I think I tried taking out that servlet dependency, but let me verify.
12:07{blake}And I think one doesn't need the ring-jetty-adapter any more, either?
12:08jcrossley3{blake}: uh, not if you're running on wildfly, no :)
12:10{blake}jcrossley3: Yeah, but we don't even need it for running locally, I think... (lein ring server)
12:11jcrossley3{blake}: i think that's the only time you *do* need it, but ring should pull that in for you without declaring the dep
12:12{blake}jcrossley3: Oh, yeah, okay. =)
12:16gfrederickswhat is the goodest reload-my-code-when-files-change thing, where I really mean "when files change" and not "when an http server gets a request and files have changed"
12:17gfredericksI'm a fan of the tools.namespace refresh function, but I'd also probably need to restart my component system, and tie it to the filesystem watcher somehow
12:20PupenoDoes anybody know how to find input[name=blah] with enlive? I know (attr= :name “blah”) can filter by the attribute name, but not how to compose it with filtering only inputs.
12:50csd_i have a static anonymous class Foo$Bar where Bar extends Foo. is it possible for me to access a field on Foo through Bar? I'm not seeing it being available as an inherited property, even though its constructor calls super()
12:51gfrederickscsd_: how are you creating the class?
12:51gfredericksis this java code?
12:51csd_yeah java interop
12:51gfredericksbut Bar is defined in java?
12:51csd_yes
12:51gfredericksand you want to write (.fooThing my-bar)?
12:52csd_yes
12:52gfredericksand you get an error about fooThing not existing?
12:52csd_yeah, because its a static anonymous class
12:52gfredericksthe error message says that?
12:52csd_no i mean, Bar is a static class defined in Foo.class
12:53gfredericksand we're talking about instance variable, not a static variable?
12:53csd_instance variable on Foo
12:54gfrederickssounds like it should work
12:54csd_idk i'm using timmc's handy `show` function and none of the parent fields are available
13:01Bronsacsd_: can you show an example of the java code?
13:02Bronsacsd_: not sure if this is the case but javac compiles some code using internal field to get around mismatches between jvm's access policies and java ones
13:04TimMccsd_: Pass {:inherit true} as a second arg.
13:05TimMcoslt
13:15justmytwospencesilly question here: is clojure's substitution model such that parallelization is or could be automatic? It seems like the syntax tree is so explicit in clojure that this should be possible.
13:16justmytwospencehm perhaps this is a question for #clojure-beginners?
13:17chouserjustmytwospence: clojure currently promises to evaluate fn parameters in order, so making it automatically parallel would be a breaking change in the semantics of the language.
13:17chouser...I don't know if that answers your question or not.
13:21TimMcI have relied on eval order.
13:21justmytwospencei see
13:22justmytwospenceis anyone aware of a particular language that do behave that way?
13:23TimMcI know some Schemes do specifically say "no guarantees", one even going so far as to use a very strange eval order (evens first, then odds in reverse order?) but I don't know if any take advantage of that opportunity.
13:23chouserthe "lazy evaluation" languages do not promise particular evaluation order, so auto-parallelization should be possible. Haskell is one of these.
13:24hiredmanhttps://en.wikipedia.org/wiki/Automatic_parallelization may be a good place to start
13:25hiredman(I would start at https://en.wikipedia.org/wiki/Automatic_parallelization#Difficulties, but that ruins the surprise)
13:26Thomas`Is nginx the only way to handle a compojure app that is accessed via subdomain? e.g., "sd.example.com".
13:28TimMcThomas`: No, you could have the subdomain's A record point to your host and compojure listens on port 80... but I have a feeling that's not exactly what you're asking about.
13:29wasamasaThomas`: should be able to do with some ring hackery
13:29TimMcDo you mean vhost stuff?
13:31Thomas`Last time (months ago) it didn't work. I'll try again and see what happens.
13:32hiredmanhttps://github.com/weavejester/clout
13:32hiredman^-
13:32hiredman(read the docs, that is the library compojure uses for routes)
13:32tmtwdI put (run-jetty handler {:port 3000}) in the repl, how do start a new cider repl to interact and/or how do I break out of this process?
13:37justmytwospencethanks chouser TimMc hiredman
13:38justmytwospenceI was using process substitution at the command line the other day and was just curious why I've never heard of a language operating the way it does
13:39justin_smithtmtwd: I I think there is a way to tell jetty to run in a new thread, otherwise you can just do (future (run-jetty ...)) instead
13:39justin_smithtmtwd: also, you can use M-x cider to connect to the same open port
13:39justin_smith(whichever port the existing cider repl was using)
14:12bittsr/fold works great for processing large collections in parallel. Now I have a small collection (2-10) of somewhat longer running tasks (1-2 seconds) that r/fold decides to execute on a single thread.
14:12bittsIs there anyway to force it to use N cores, Or is there something totally different, like an explicit thread pool?
14:13Bronsabitts: IIRC you can supply an `n` parameter to r/fold to tell it into how many groups to partition your coll
14:14BronsaI just looked it up actually. you probably want the [n combinef reducef coll] arity
14:16hiredmanbitts: you aren't doing io using fold are you?
14:17bittsBronsa: thanks. Right I remember now 512 is the default.
14:19bittshiredman: doing some CPU only and I'm inserting 1.5M rows into the DB using fold. I tried with and without fold. With it uses all 8 cores with the default size of 512. Much faster with 8 cores inserting.
14:19hiredmanuggh
14:19hiredmandon't do that
14:19hiredmanhttp://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ExecutorCompletionService.html
14:20hiredmanhttp://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html
14:20hiredmanetc
14:22bittshiredman: I saw that too. "Work to be performed is computation (not I/O or blocking)" at the bottom http://clojure.org/reducers
14:22hiredmanfold uses a forkjoin threadpool, those are designed for compute bound tasks
14:22bittshiredman: why?
14:22hiredmanwhy what?
14:23bittshiredman: Why not use fold for i/o. The docs simply say don't and you're daying don
14:23bittsdont'. but why what's the issue.
14:25hiredmanbecause there are different trades offs for blocking tasks and compute heavy tasks for scheduling work on a threadpool and forkjoin is designed for compute heavy tasks and fold is built on forkjoin
14:26hiredmanforkjoin has some facilities for telling the pool will block, but the simplified model presented by fold doesn't expose that, and I am not sure how well it works in any case
14:27hiredmanyou certainly want an Executor in any case, because you want to specify exactly how many threads should be working on whatever, where as you don't have control over that with fold (as you have seen)
14:31mgaareany hints for debugging log4j/slf4j issues? I'm getting an infinite loop somewhere causing a stack overflow on starting repl: http://pastebin.com/h0urpgQT
14:33justin_smithmgaare: I assume this is with lein repl auto-loading your main namespace?
14:33justin_smithmgaare: or does this happen even when starting a normal clojure.core repl in hte user ns?
14:33mgaarejustin_smith: I have a file that defines a user ns
14:35mgaaredoesn't happen when I remove that file
14:38mgaareprobably due to this, I think: http://www.slf4j.org/codes.html#log4jDelegationLoop
14:40mgaarenot that exactly, but something like it
14:49mgaareok, solved it. did lein deps -tree and found both org.slf4j/log4j-over-slf4j and org.slf4j/slf4j-log4j12 being brought in
14:49mgaareer :tree
14:54lodin__Other than not being able to do a :refer :all (without :exclude or :rename), is there any downside with doing (ns-unmap *ns* 'System) (defprotocol System ...)?
14:56lodin__Could e.g. the ns-unmap call mess with AOT compilation, or what-not?
15:22justin_smithgfredericks: it's awesome following that cheshire issue right now
15:22justin_smithgfredericks: really glad you are doing this (sorry I didn't do it sooner)
15:28gfredericksone failing test left
15:28gfredericksjustin_smith: want to debug it for me? :D
15:29justin_smithgfredericks: haha, maybe I can later, leaving for lunch soon, but sure!
15:37gfredericksjustin_smith: branch linked on the issue
15:37justin_smithcool, I'll check it out later, thanks
15:43weskinner_workDoes anyone know how to do password confirmation validation with bouncer?
15:46scriptorI'm using evil mode, problem is that means I can't seem to get Cider's M-. binding to work
15:46scriptoranyone know how to work around that?
15:47scriptorit's probably because . is vim's repeat command key, but if I'm doing M- first it shouldn't use that
15:49wasamasaunbind M-.
15:50wasamasaas M-. is bound to another command in evil's normal state map
15:51wasamasayou should really be asking this in #emacs :P
15:51scriptoryeah, doing so now
16:27rasmusto_scriptor: also, see spacemacs :)
16:32hellofunkrasmusto_: spacemacs looks interesting, thanks
16:38tmtwdhow do I open a lein repl directly through emacs (rather than cider-jack-in)?
16:40Reefersleep_hello
16:41Reefersleep_I have a reagent\figwheel application which I’m hosting on github pages
16:41Reefersleep_but it’s like the css isn’t loading
16:42Reefersleep_(when I access my index.html, I mean
16:42rasmusto_hellofunk: just turn on the paredit, autocomplete, and clojure configuration layers and you have a working emacs/vim hybrid setup
16:42arrdemtmtwd: cider-jack-in does create a bare (headless) lein repl and then connects to it over nREPL. What are you trying to do?
16:42tmtwdarrdem, okay thanks
16:42tmtwdI think that's what I wanted
16:43arrdemok
16:43arrdemyeah you probably don't need anything else.
16:43Reefersleep_when I go to the index.html in the folder on my computer and load it into the browser, everything is fine
16:43Reefersleep_anyone have a clue what I’m doing wrong?
16:44Reefersleep_This is my github page
16:44hellofunkrasmusto_: i think i'll give it a try. emacs key chords are starting to drag down my worldview
16:45Reefersleep_this is my github repo: https://github.com/Reefersleep/derpanet
16:45oddcullyReefersleep_: just to have it mentioned: there is also #clojurescript
16:45Reefersleep_cheers oddcully :)
16:46oddcullyReefersleep_: have you looked in the net-tab of your devtools, if the files just gets a 404 or something alike?
16:47Reefersleep_why didn’t I do that
16:47Reefersleep_yes, my .js is getting a 404
16:48Reefersleep_don’t see why, though
16:49oddcullyReefersleep_: the file is on that server? the paths are right? can you copy the url there and test for yourself? is the request cross-http/https and is your browser blocking it?
16:51Reefersleep_the path matches the one I see in my local folder
16:52Reefersleep_I *just* pushed it to the github page
16:52Reefersleep_it shouldn’t be cross-http, it’s the very same site
16:52Reefersleep_it’s just /js/compiled/file.js
16:53oddcullythe leading / means an absolute path for that domain. is this the case?
16:53Reefersleep_the URL is http://reefersleep.github.io/resources/public/js/compiled/derpanet.js - I get a 404 on going there
16:53Reefersleep_well… I don’t know.
16:54Reefersleep_The index.html file, which I’m viewing, is in the same folder as the js folder
16:56oddcullywell the css is there. never used githup.io myself, so is there some way to look, whats actually there?
16:57Reefersleep_I don’t know, I’m completely green :)
16:58Reefersleep_with github.io, that is
16:59amalloyso, Reefersleep_, the thing is, i don't see any evidence your .js file exists
16:59amalloylike, github.io is just serving files directly out of https://github.com/Reefersleep/Reefersleep.github.io as far as i know
17:00amalloyand there is no .js file to be seen
17:00amalloyit doesn't invoke lein cljsbuild for you or whatever other thing
17:00Reefersleep_uhm
17:00Reefersleep_you’re right
17:00Reefersleep_wtf happened
17:01Reefersleep_the .js is in my local folder
17:01Reefersleep_which I just pushed
17:01amalloywell, check your gitignore, and whether you've added/committed before pushing
17:03Reefersleep_amalloy
17:03Reefersleep_the folder is in gitignore
17:03Reefersleep_I think you saved me :)
17:03Reefersleep_no idea why it’s there, though
17:04amalloybecause you would ordinarily not want to commit compiled files to your github repo
17:04oddcullythe figwheel template has it
17:04oddcullyit's autogenerated stuff there
17:04oddcullyso it's usually sane to ignore it
17:04amalloyonly in the special case where someone is serving directly from your git repo, rather than building and then serving, would you want to check that in
17:05oddcullytrue, but maybe only with a min-build
17:06Reefersleep_thanks a lot, both of you
17:06Reefersleep_I’m going to try and work this out
17:07Reefersleep_I get why it’s ignored to begin with
17:07Reefersleep_I didn’t expect the lein figwheel template to have anything specified in the .gitignore file
17:07amalloyReefersleep_: pretty much every lein template has stuff in gitignore
17:08amalloyyou can just git add -f js/compiled/whatever.js
17:08Reefersleep_I’m pushing to both the pages repo and to my github repo from the same local file
17:08Reefersleep_so actually it’s fine that it’s normally ignored
17:08oddcullybut be aware, that the file will change extremly how it gets built
17:08oddcullyif you build with min then there is one huge mess of js
17:08Reefersleep_amalloy are you saying that I can one-off push that file to a particular repo?
17:08amalloyno
17:08Reefersleep_oddcully what do you mean, min?
17:09oddcullyif you have the dev build there is the file and the out/ dir
17:09Reefersleep_I build with figwheel, I guess? And whatever plugin takes care of autobuilding
17:09oddcullyif you run figwheel it uses the dev config to build the js files
17:09Reefersleep_yeah I use the dev config
17:10oddcullybut for release you want to do a build with the min setting (e.g. lein clean && lein cljsbuild once min)
17:10oddcullysee the project.clj for the config of both
17:10Reefersleep_aha
17:11Reefersleep_oddcully: Do you have a tip on how to push something to one repo, and not the other?
17:11Reefersleep_I’m (also) a github newb :l
17:11Reefersleep_*git
17:12Reefersleep_guess I could do a commit, push it to one repo, then just undo the commit locally?
17:13oddcullyim a github.io noob ;)
17:13oddcullymy approach would be to separate this in two repos maybe
17:14Reefersleep_rasmusto_: I’ve been thinking about getting into emacs. Could you repeat what you told hellofunk earlier? I dig vim bindings ;)
17:14oddcullythen let your build build that stuff into the other and push that
17:14arrdemis there a good Make channel?
17:14Reefersleep_oddcully that makes sense, maybe
17:14Reefersleep_no idea how to set that up - the build process, I mean
17:14oddcullyfirst of all, i'd check, how others do
17:14oddcullythere are lots of nikola/octopress/younameit pages on github.io
17:15oddcullyunless github builds stuff for them, they have the same problem
17:16hellofunkReefersleep_: he was basically saying to check out spacemacs
17:17oddcullyhellofunk: me? never! i'd go with arrdem's make
17:17amalloyarrdem: i don't think so; i'd just try the C channel
17:20Reefersleep_hellofunk: really? or are you saying that it would be equivalent to what he’s saying? :)
17:20Reefersleep_oddcully: good suggestion
17:35SeyleriusIs there a simple way to pass several keys of a map as args to a function?
17:35amalloy(apply f (map m [a b c d]))
17:40hellofunkReefersleep_: he said to check out spacemacs
17:40hellofunkoddcully: ??
17:40lazybothellofunk: Definitely not.
17:40Seyleriusamalloy: Thanks
17:40Seylerius(inc amalloy)
17:40lazybot⇒ 285
17:40randomcharhereWhats the syntax in clojure for ((x < 10)&&(y < 10) )
17:40Reefersleep_hellofunk: cheers :)
17:41Reefersleep_(and (< x 10) (< y 10)) ?
17:41hyPiRion(and (< x 10) (< y 10))
17:41Reefersleep_maybe
17:41randomcharheredoh thanks :)
17:42randomcharheretrying to piece together a clojure education from disparate web site and books couldnt find something so simple anywhere
17:43amalloyalso, (every? #(< % 10) [x y])
17:43amalloythere are lots of ways to write stuff
17:43randomcharherecool
17:43Seylerius,(doc filter)
17:43clojurebot"([pred] [pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-effects. Returns a transducer when no collection is provided."
17:43zimablueI was waiting for someone to shorten it, sitting here thinking how
17:44Reefersleep_hehehe
17:44zimablueis partial idiomatic in clojure? it constrains you to only binding the first variables right? as in you can't bind 2 and leave 1 open if that makes sense
17:45zimabluebecause I was thinking you'd have to do something like (partial ( > 10)) whatever the syntax is
17:45hellofunkzimablue: partial is definitely idiomatic. but there are other ways to do things too, like pass a literal if your args aren't in order
17:45zimabluepass a literal?
17:45arrdem( ... #(foo % 3) ...)
17:45hyPiRionzimablue: You can do (partial > 10), but in this case you know that you will take exactly one argument.
17:45hellofunk#(> % 10)
17:46lodin__zimablue: Beware that (partial f (g x)) and #(f (g x) %) are not equivalent though w.r.t. the time of evaluation of (g x).
17:46hyPiRionAnd #(< % 10) is going to be faster to run than (partial > 10) unless that has changed recently
17:46amalloyhyPiRion: most applications of partial you know exactly how many args you will have, so i don't really get the "but" there
17:47amalloylike i don't use partial a lot either, but i don't consider whether i know how many args are left when deciding whether to use partial
17:47zimabluethe last thing I read was haskell so I always feel like lambdas are naughty but I guess they're idiomatic/unavoidable. lodin__ I should know but I'm guessing partial is the one evaluating up front?
17:48hyPiRionamalloy: Eh, maybe not. I don't use partial if I can use function literals or (fn [...] ...)
17:48arrdemif only we had currying... /me ducks
17:48amalloyhyPiRion: well uh...you can always use those. so you are saying you never use partial
17:49hyPiRionamalloy: But it's shorter to write (partial + 1) than (fn [& v] (reduce + 1 v))
17:49lodin__zimablue: Yeah, partial is just a function, so the arguments are evaluated before it is passed. Something this is what you want, particularly if the function is going to be called several times, and g is costly.
17:49hyPiRionoh, I see that I didn't include that. Well. I use the thing most readable.
17:50zimabluethanks, that's a really interesting point
17:50amalloywe can all get behind that, hyPiRion
17:50Seylerius,(doc ->)
17:50clojurebot"([x & forms]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
17:50amalloyalso, (partial + 1) is a fun example, because you can write it without partial or lambdas: (comp inc +)
17:51Reefersleep_amalloy / oddcully : Just for kicks, I decided to try to remove the line from my .gitignore, git add my js folder, commit and push to my github page repo
17:52Reefersleep_so now the app works :D and I just have to undo what I did and make a new commit in order to push normally to my dev repo
17:52hyPiRionamalloy: ahh, you and your tricks. (partial + 10) then, unless you prefer (comp inc inc inc inc inc inc inc inc inc inc +)
17:53amalloyhyPiRion: (comp inc inc octoinc +)
17:53Reefersleep_amalloy / oddcully: you can view the site here if you feel like it: http://reefersleep.github.io/resources/public/index.html
17:53zimablue(iterate 10 inc) >
17:53lodin__zimablue: Why did reading Haskell make you feel like lambdas are naughty?
17:53rasmusto_Reefersleep_: spacemacs
17:54Reefersleep_rasmusto_: cheers. Dansker?
17:54amalloyyou don't need lambdas nearly as much in haskell because of currying, and when you do need them you can often shove them into a where clause. so if you see a lot of lambdas in a haskell function it is "usually" not that well written
17:55oddcullyReefersleep_: cool
17:56Reefersleep_it’s unfinished of course :)
17:57hellofunk(inc amalloy)
17:57lazybot⇒ 286
17:58Reefersleep_(inc hellofunk)
17:58lazybot⇒ 3
17:58oddcullyReefersleep_: you have upped the :dev build now - since it's not your upstream there, you might consider the time users have to wait. if you build the :min one, there will only be one .js file to download
17:59Reefersleep_ah ok, so just do those two commands you mentioned and then commit that instead of what I’ve got now?
18:00oddcullyyes, but you will see a _huge_ diff with this
18:00oddcullyso for now while dev'ing things, you might stick with :dev
18:00oddcullyi just wanted to mention this
18:01oddcullythe :min build will turn all your out/**/*.js files into one blob of optimized js
18:01Reefersleep_ah alrigh
18:01Reefersleep_t
18:01Reefersleep_this stuff is tricky. I need an automated release build process, really
18:01Reefersleep_Like you suggested.
18:04Reefersleep_But for now, I’m just happy that it’s up, really! :D
18:12zimabluelodin__I didn't write lots of it I mostly just wanted to understand it but I think I remember reading that they prefer to write it in that headless way where you don't have an explicit variable on both sides of an arrow, if that makes sense.
18:13csd_``I've got functions A and B. A takes a channel and returns nothing. B is not asynchronous and returns a hashmap. A needs to be called before B. The problem is, A and B are wrapped in the let that defines the channel passed to A, and B is going to have its own result that will need to be bound. Meanwhile A returns nothing. So it seems like I'm left with the option of either having A inside the let but binding _, or having a nested l
18:13csd_``B. Or i could use an atom or something i guess. I don't love any of the options. Can anyone suggest what might be best?
18:13zimabluepointfree that's it
18:21lodin__zimablue: Like double = (*) 2 instead of double x = (*) 2 x, you mean.
18:21justin_smithcsd_``: first part of your question is cut off, but one option for sync (if one thing that is async has to get to a specific point in its computation before something else should run) is to have the async thing deliver a promise, and have the sync thing explicitly deref the promise before doing its thing
18:22SeyleriusIf I've got a series of strings that go "Bla blah blah. Blah Blah. High foo. Blah Blah Blah.", what's the easiest way to filter that into everything before the word "High"?
18:22csd_``justin_smith: i'm more concerned with style than the syncronicity
18:23zimabluethere's a thread here where they argue both sides of it a bit: http://www.reddit.com/r/haskell/comments/2fbe4t/compose_to_avoid_lambdas/ is there an argument to be made in clojure that lambdas would be somehow harder to integrate with macros?
18:23Seylerius,(doc map)
18:23clojurebot"([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments. Returns a transducer when no coll...
18:23lodin__Seylerius: If it's a string then a regexp would be good, I figure.
18:24justin_smithcsd_``: OK, the part of your question that had your actual question in it was cut off then
18:24SeyleriusOff I go to a clojure regexp guide, then.
18:24SeyleriusThanks, lodin__
18:24Seylerius(inc lodin__)
18:24lazybot⇒ 1
18:24justin_smithSeylerius: they are just java regex
18:24Seyleriusjustin_smith: Great, thanks.
18:24justin_smithor js regex, for cljs
18:24csd_``justin_smith: basically i'm trying to simplify this (let [c (chan)] (init-async-thingie c) (let [foos (mk-foos)] (use-the-foos c)))
18:24csd_``if that makes sense
18:25Seylerius(And yes, I pass points around like candy. I like my gratitude to count)
18:25justin_smithyeah, I would move (mk-foos) into the first let binding
18:25Seylerius(inc justin_smith)
18:25lazybot⇒ 273
18:25csd_``justin_smith: and bind the init-async to _ ?
18:25csd_``it has to occur first
18:25justin_smithyeah
18:25csd_``ok
18:26lodin__Seylerius: Clojure has syntax support for regexps via #"regexp-goes-here".
18:26csd_``i'm generally unclear on whether using side effecting actions in let bindings like that is ok
18:26justin_smithcsd_``: that's why we have that _ idiom
18:27csd_``got it, thanks
18:34randomcharhereHow do I add more data to an array pf vectors?
18:35justin_smithwhat is a pf?
18:35randomcharheresorry typo of
18:36justin_smithrandomcharhere: conj for the vectors, for the array you are out of luck, maybe you can use a vector instead, or make a new array
18:36randomcharhereI use def to define one but cant seem to add more data to it
18:36justin_smithrandomcharhere: vectors are immutable
18:36justin_smithyou need to use def again, or use the return value of conj directly. The original will not change.
18:36randomcharherenot looking to change the data just keep adding to it
18:36justin_smith,(def a [])
18:36clojurebot#'sandbox/a
18:36justin_smithrandomcharhere: adding is a change
18:37justin_smith,(def b (conj a 1))
18:37clojurebot#'sandbox/b
18:37justin_smith,b
18:37clojurebot[1]
18:37justin_smith,a
18:37clojurebot[]
18:37justin_smitha did not change
18:37justin_smithyou cannot add anything to a (but you could use def again and replace a)
18:40randomcharhereso how do you keep track of a large array without having to copy the thing over just to add some more data?
18:41justin_smithrandomcharhere: by not using defs for things that should change
18:41justin_smithrandomcharhere: typically we'd have something like reduce or loop where each iteration sees a new vector with the new data added
18:41justin_smithbut there is no single vector mutating - it's a new argument coming in each time
18:43amalloyrandomcharhere: remember that getting a changed copy of a vector (or map or whatever) isn't "copying"
18:43lodin_randomcharhere: The way vectors are implemented you don't need to copy the whole vector when you add to it.
18:43amalloyit behaves the same as copying, but is implemented more efficiently
18:44justin_smithyeah, good point, the original does not change, but the whole thing isn't usually copied (only a small part)
18:45randomcharherehmmmm ;/
18:46justin_smithrandomcharhere: because the vector is guaranteed immutable, we can share the same data in two vectors
18:46justin_smithrandomcharhere: which means we don't need to do much copying
18:46lodin_randomcharhere: Do you know how a linked list works? (Vectors are not linked list, btw.)
18:47justin_smithlodin_: oh, yeah, that's a good example, two linked lists can differ only by the head
18:47randomcharhereunderstood but how do I create a vector/array whatever so I can add more data to it?
18:48justin_smithrandomcharhere: with []
18:48randomcharherestarted with (def a [ (vec (for [x (range 3) y (range 2) ] [x y 0]))])
18:48randomcharherejust an example
18:49justin_smithrandomcharhere: here's an example ##(loop [acc [] new (rand)] (if (> (count acc) 3) acc (recur (conj acc new)))
18:49justin_smith,(loop [acc [] new (rand)] (if (> (count acc) 3) acc (recur (conj acc new)))
18:49clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
18:49justin_smitherr
18:49amalloyjustin_smith: just one more ) at the end
18:50randomcharhere:P
18:50justin_smith,(loop [acc [] new (rand)] (if (> (count acc) 3) acc (recur (conj acc new) (rand))))
18:50clojurebot[0.7726313852857776 0.4344170843561387 0.11577137255160963 0.1291733565449812]
18:51justin_smiththat's a silly loop, but at least it shows the principle - each new vector is the arg of the next loop iteration
18:51justin_smithrandomcharhere: we don't use def for things that are meant to be updated (unless it's a container for mutation, like an atom)
18:52randomcharhereI feel like still missing something
18:52justin_smithrandomcharhere: we have constructs that are meant to use a new set of args on each iteration
18:52justin_smiththey don't need to mutate anything to accumulate data
18:52lodin_,(let [a [1 2] a (concat a a)] a)
18:52clojurebot(1 2 1 2)
18:53justin_smithlodin_: that's misleading because it's shadowing
18:53lodin_But I think that is what randomcharhere wants.
18:53justin_smithsure, but that's just one a hiding the other, but it might look like a wes changing
18:54justin_smith,(let [a 0 b (fn [] (println a)) a 1] (b))
18:54clojurebot0\n
18:54lodin_justin_smith: And the next step would be fore randomcharhere to realize that. :-)
18:54lodin_s/fore/for/
18:55randomcharhereJust so use to coming from c c++ python ... ti assining a variable and being able to mangle/spindle what not that variable
18:55justin_smithrandomcharhere: right, we don't really do that much
18:57lodin_randomcharhere: Right, so instead of a = stuff(...); a.sort(); you do (let [a (stuff ...) a (sort a)] ...). In real code that would probably be written differently, but you get the idea.
19:03randomcharherehmm guess'll go bang my head againt the wall some more :p
19:05justin_smithrandomcharhere: it requires a different style of programming. If you haven't done functional programming with immutable data before, I'd recommend finding a good book.
19:06justin_smithclojure programming if you're experienced with other languages, clojure from the ground up or clojure for the brave and true if you are less experienced
19:08phren0logyI got the early-access of Clojure for the Brave and True and found it to be harder to follow than Living Clojure.
19:08randomcharhereIronically most books I've found will "list" all the commands and desribe them
19:11amalloyrandomcharhere: it may help to think about recursion: because there's no way for clojure programmers to modify a value, we need some other place to store a new "version" of that value. the stack is a convenient place to do that, and that's what recursive functions do: produce new stack frames to hold values in
19:12amalloyeg if clojure is new to you, and you're having trouble getting the immutability and the new syntax at the same time, try writing a function in python that does something without any mutation. for example, implementing multiplication in terms of addition is a fairly simple one
19:12amalloy(and yet often still hard if you aren't used to thinking that way)
19:12lodin_randomcharhere: Maybe a fun (?) exercise would be to try to write Python but all lines that don't have a return value are banned, except def, if, and return. You are allowed to have a module called "functions" in which you break these rules and can do whatever you want, so e.g. sorted would be in functions and be "def sorted(xs): ys = list(xs); ys.sort(); return ys;" if it wasn't in Python already.
19:13lodin_Then, when you have gotten going, also add the requirement that the function are not allowed to modify their arguments. But that can wait.
19:14lodin_s/function/functions/
19:16lodin_Assignment is also allowed, but x[k] = v is not, because that's sugar for some method call.
20:30SeyleriusIf I need to grab and process multiple things from an API, and need to wait 6 seconds between API calls, what's the most efficient way to ensure this happens?
20:44ToBeReplacedSeylerius: I'd use a ScheduledThreadPoolExecutor to make calls and put results on a channel
20:54bucketh3adHey. I'm wondering if anyone has any experience with sparkling, the clojure library for apache spark. I'm going through the tf-idf tutorial right now and I've run into an error I can't figure out.
21:03SeyleriusDoes anyone have a guide on how to use ScheduledThreadPoolExecutor in Clojure?
21:34ToBeReplacedSeylerius: you should learn java interop and then reference the javadoc https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html
21:36ToBeReplacedi've done the exact thing you're trying to do with an external service that i had to play nice with, but the code is closed so i can't offer an example
23:36SeyleriusHow do I spin off a thread and have two-way communication with it? Basically, I want to spin off a thread that waits for something sent into its channel, marks the time, does shit with sent thing, and then sends it back, then waits until it's at least 6 seconds after the marked time, then repeats.
23:37SeyleriusAnd I want the original thread to then be able to stick shit into the channel, wait for a return, and then continue processing.
23:38justin_smithSeylerius: sounds like core.async
23:39Seyleriusjustin_smith: Would I make two channels, and then define the thread to read one and write the other, and at the same time have the originating thread write the first and read the second?
23:48justin_smithSeylerius: sounds about right, a common practice in core.async is to send a channel along with your request, and have the other end send the result back to the channel you sent in
23:49justin_smithkind of like a callback on an ajax call, but with threads, and with channels