This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-07
Channels
- # admin-announcements (4)
- # aws (2)
- # beginners (25)
- # boot (116)
- # braid-chat (4)
- # cider (6)
- # cljsjs (4)
- # cljsrn (17)
- # clojure (196)
- # clojure-austin (23)
- # clojure-belgium (5)
- # clojure-dev (78)
- # clojure-dusseldorf (6)
- # clojure-italy (2)
- # clojure-japan (6)
- # clojure-poland (1)
- # clojure-russia (132)
- # clojure-sdn (1)
- # clojure-uk (26)
- # clojurescript (87)
- # code-reviews (3)
- # core-async (26)
- # cursive (8)
- # datomic (40)
- # devcards (8)
- # emacs (4)
- # funcool (32)
- # hoplon (30)
- # jaunt (34)
- # jobs (1)
- # lein-figwheel (1)
- # leiningen (5)
- # om (14)
- # onyx (8)
- # overtone (31)
- # parinfer (14)
- # proton (8)
- # protorepl (1)
- # re-frame (30)
- # reagent (10)
- # spacemacs (2)
- # untangled (107)
- # yada (3)
apodini is one, but I'm curious if Rackspace recommends one in particular: https://github.com/sonian/apodini
It would be really nice to be able to use data.csv in eg planck or other selfhosted clojurescript environments.
apply works like a specialized form of map, and map is a specialized form of fmap for list kind, would that be fair
I don't agree with "apply works like a specialized form of map" at all -- that would imply you can implement apply on top of map, which you cannot
what I tried to say, by the special form is (apply str '("hello" " " "world!”)) the similarity to (reduce + ‘(1 2 3 4)), just used reduce since the other one is str, so you have a function and a type as input and get back another type, which I thought is fmap
I’ve heard good things about http://www.braveclojure.com/
There's also Eric Normand's http://www.purelyfunctional.tv if you prefer entertaining videos to text.
@bronsa: apply is nothing like fmap? Okay. It’s iterating over a sequence though. Sequence is (typeclass-ish). Yes map is not a specialised version of apply as map is fmap, what I meant is function application over a sequence.
apply
doesn’t iterate over a sequence
@urbanslug: they're doing fundamentally different things though, so I really don't think even comparing them makes sense. apply
takes all the items of a sequence and invokes a function over all of them, map
iterates over those items applying f over each one of them
@urbanslug: apply transforms a sequence into arguments: (apply foo [a b c d])
↠ (foo a b c d)
, so no iteration right?
There are so many little magical functions in Clojure (I discovered juxt
when it was being discussed here, and tentatively used it today) that it takes a lot of practice with them to remember what does what
Dear JVM people, discovering this was not cool: (format "0x%x" (bit-shift-right (byte -128) 1)) ; => "0xffffffffffffffc0"
😛 that is, when bit-shifting a byte, I did not expect my byte to be silently upcast to signed Long, shifted, and returned as a Long with a bunch of leading 1s. I wrote up a description of JVM/Clojure bitbanging semantics at https://clojuredocs.org/clojure.core/bit-shift-right#example-570683fae4b0fc95a97eab30 but still a shock.
Java isn't a great language for bit-manipulation in general. No unsigned byte types.
And Clojure's default coercion to Long
makes it worse.
@stuartsierra: absolutely, it's my fault for coming in with assumptions. I vaguely knew that JVM didn't have some unsigned types but I didn't make the connection from that to my failing code 😛
But now it's all sorted and I'm getting some nice data on this Raspberry Pi (`lein repl` start time: 2 minutes!) from my sensor via RS-232 serial 😄
2 minutes !!
tcrawley: I don’t think Rackspace officially recommends a Cloud Files client for Clojure. For Java, it recommends jclouds. There are Rackspace Cloud Files specific plugins, but the regular OpenStack one works just as well. There have been projects to port jclouds to Clojure but AFAIK all of them have pretty much stopped. We’re using RCF internally (well, as a private cloud user) so if you figure out which one works well, I’d love to know 😛
@lvh: after my ? last night, I discovered the clojure that ships with jclouds, and have been using that to play with. I'm not yet sure if I like it
tcrawley: I wrote some stuff a long time ago to make it more pelsant to use, and I’m not really sure I succeeded
guys, how can I “beautify” big chunk of edn? I have it in my clipboard, inserting that in Emacs buffer with clojure-mode on, hangs Emacs. I couldn’t find a way to do that in Atom or LightTable
if you have huge chunks of edn, you might want to consider a binary format like fressian instead
there is a certain point (which may be subjective) where the scale of the data makes the fact that you encode it in a human friendly way (json, edn) irrelevant
if you have a bunch of data, and suddenly you need to add new process of that data, which is bottlenecked on reading and writing edn, what are you going to do?
well yes that would be exactly one of those very specific situations one is unlikely to encounter in real life, and when you are, you usually know well in advance
my experience is people choose an easy to inspect encoding like edn, and then pay for it later
it completely depends upon the use case, but i have yet to encounter a single case where that happens -- usually when things go so big that you need binary serialization, you have multiple very qualified engineers working on the project, and they know well in advance when to choose such an encoding type
(defn contains-key [seek-key hashmap]
(loop [[k, _] (first hashmap)]
(if (= seek-key k)
true
(if (nil? k)
false
(recur (first (dissoc hashmap k)))
)
)
)
)
; execution timeout; someone has better eyes than me ; this is a silly exercice as I'm getting familiar with clojure. I do know I can do it in one liner thanksA clearer implementation perhaps would be
(defn contains-key [m k]
(loop [[entry & rest :as coll] (seq m)]
(if (empty? coll)
false
(or (= (first entry) k)
(recur rest)))))
ok, so let’s say you have a seq of key-value pairs, and you want to put them into an array-map (so they are in the order that you inserted them)...
so it converts to a hash-map on the 10th item
they only way I’ve found to get what I want is this...
if you insist on doing that, the way to think about it is, maps are an index of a key to value, and you want a second index of numerical order to map entry
but I haven’t been able to get any incantation of conj, into, or assoc to keep it an array-map
yeah, but I need both lookups by key and ordering
but in general, I would go hidredman's route of avoiding the need to have an ordered map if at all possible
because the values in the map have a dependency order
if you want to get really fancy use clojure.set/index to build little database like things
https://github.com/stuartsierra/dependency/blob/master/src/com/stuartsierra/dependency.cljc is likely more complicated than you need
If you want to preserve insertion order, the easiest thing is probably a map plus a vector of keys.
if you want to make a deal with the devil, you can use LinkedHashMap too (the deal being mutability of course :)
but really, don't do that :)
(defn contains-key [seek-key hashmap]
(loop [newhashmap hashmap]
(let [[k, _] (first newhashmap)]
(if (= seek-key k)
true
(if (nil? k)
false
(recur (first (dissoc newhashmap k)))
)
)
)
)
)
defn contains-key [seek-key hashmap]
(loop [newhashmap hashmap]
(let [[k, _] (first newhashmap)]
(if (= seek-key k)
true
(if (nil? k)
false
(recur (dissoc newhashmap k))
)
)
)
)
)
; here you goAlso, you didn't ask for this, but you should group up all the trailing parens together, instead of trying to use them to 'see' the scopes like you would with curly braces.
Does anyone know how to get clj-time to keep the timezone from the DateTime object when creating a TimeStamp?
@pmooser: it alows me to not forget parens and fix it quickly ; im not sure im a fan of the parens. still getting used to it
6ewis, it's fine to prefer that style, but the likelihood is that there's not actually a benefit to it. You'll be better off if you stop doing it, but feel free to ignore my advice.
Alternatives that I have found are helpful are tools to have you - a syntax-aware editor, or things like paredit. Ok, enough unsolicited advice.
@lewix: you'll quickly get used to the conventional style, which helps immensely reading code, and with some editor tools like paredit/parinfer, you'll never have to deal with parens manually
@bronsa: @futuro I used vim that supported some parens lib, i used light table and now im using cursor - and I still prefer this style (in your defense I use it all in the span of a week)
@futuro: Does this help you at all? http://stackoverflow.com/questions/5942702/how-to-preserve-time-zone-in-joda-time-timestamp
how do I get the version specified in the project.clj from the command line? Hoping there is a command to do it for shell script?
@lewix I don't mean to be pushy about this - honestly I'm trying to help because I've seen this many times before. I work in a bunch of languages, and I try hard to adopt the common conventions in each language, because they're not the same. When I write js, I format it like people format js.
i dont actually think the problem is that 6ewis should be able to "parse" the parens in his head -- i never count them myself -- i just let the editor do the work. @lewix my strong advice is to bite the bullet and learn how the editor can manage the parens for you, rather than resorting to esoteric ways of aligning them
@pmooser: you're trying to help but you're not listening - as im learning it's not helping so i remove some mental load by arranging the parens in a fashion that does not add extra thinking time
I'm listening - I think you are overvaluing your immediate comfort level. I've literally been where you are now, 8 years ago.
Look, nevermind. Unsolicited advice is obviously not useful to you in this case. Good luck.
similar like learning how to code with the REPL -- better learn that as quickly as possible
@pmooser: @lewix When I started learning clojure I was doing the same. But mainly because I was copying around a lot of stuff and keeping parens farer below is immensly helpful with that. Starting to take the parens below does not mean you will do it forever. I adapted the community style a bit later without problems.
Does JodaTime just automatically understand that a -5 offset might mean something else for part of the year?
@futuro: why stop there? UTC all the time!
the world would be a better place if everyone were on 24 hour UTC
@bostonaholic: Are you sure about that? We'd still need to understand when people in other parts (parts other to our place of residence) are generally awake.
is that different than knowing who is awake right now?
or in 6 hours from now
basically, if I say I’ll meet you at 13:30, everyone in the world knows when that is
it’s a PITA when I email with team members across the world and we have to use MST/MDT/EST, AM/PM etc.
I can understand pushing for 24 hour UST, with timezone offsets, but I'm still working through the implications of complicating removing timezones as a notion
timezones are basically crude spacial locators, and the notion that you can observe a time independently of a location is generally absurd
well, when I email someone and say “I’ll call you at 3pm MDT” and they reply with “OK, 3pm MST it is!” I have a problem with that
I just had this conversation today. If we removed timezones, we would have to find some other way to put context around time.
otherwise 3pm doesn't mean anything because you don't know if 3pm is in the middle of the night somewhere across the world
You'd still need to understand when "normal" hours are for the person you're communicating with
you need to know that either way
and timezones carry that bit of information
I still need to know when (relative to me) my colleague in Turkey is working
but if we both agree on 13:30
no other information is needed
he says “I’m available from 7 to 14"
well you can agree to communicate in GMT time, that's basically it
I mean, you could offer up a time you like, say 7-14, and he could then counter with 12-23, but you could also just ask him his "daytime interval" and start with a suggestion when he'd be awake
I believe you’re over complicating it
1) forget everything you know about time
I'm trying to build a deploy job on jenkins and failing massively. I need to get the version/jar name from the project file, but am failing spectacuarly. lein pprint :version works locally but not on jenkins
I think you might be over-simplifying it; why would you offer a time that your colleague would be asleep for?
If you only ever offer times when you're awake, you're assuming that the people you're working with are geographically close to you, right?
@base698: is the lein pprint plugin in your user profile, or is it in your project. If it’s not in your project, then it wont be available on jenkins
@mahinshaw kind of worked. do you know how to make pprint not print quotes around a string?
@base698 I don’t think you are going to get that behavior out of lein pprint. you are likely going to have to do that cleaning yourself, or fork lein pprint to add that behavior. It sounds like you want the behavior of prn
.
@base698: ohh right you need 0.1.0 not “0.1.0”. Yeah, you will have to do that in a post process step I guess
Has anyone had trouble with the component lib in the repl such that when you start, then stop, then attempt to start again, the components don’t actually start?
Same prob using weavejester’s reloaded lib, and must using my own rewrite, or using an atom (vs alter-var-root) to manage the system map, etc, etc.
They all return this or (dissoc this :some-key), but I wonder if it’s possible something somehow swallows an exception?