#clojure logs

2014-07-20

01:04wenshanHi all, I'm new to Clojure. Wondering if I can do something equivalent to generator.next (generator is implemented using lazy-seq) in Clojure.
01:05TEttingerwenshan, is generator.next a python thing?
01:06TEttingeroh I see your question
01:06TEttingerI think yes, let me check
01:06wenshanyes
01:07TEttingerlazyseqs work with nth , for one thing
01:07wenshanI'd like to do (while (< curr 1000) (progn ...))
01:07TEttinger,(nth (repeat 10) 99)
01:07clojurebot10
01:08TEttingeroh that might be easier with take
01:08TEttingerdo you have any code now?
01:08TEttingerthere's also of course loop/recur with an iterator
01:08wenshanyes, I have a prime number generator
01:09wenshantrying to get the largest palindrome prime number under 1000
01:09TEttingerpalindrome being in base 10?
01:09TEttingerlike 11
01:09wenshanyes
01:10wenshanconvert the base 10 integer to string, than check whether it's a palindrome
01:10TEttingerso your generator returns an infinite lazy seq?
01:10TEttinger(doc take-while)
01:10clojurebot"([pred coll]); Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of side-effects."
01:10wenshanI think so, I copied it from http://stackoverflow.com/questions/960980/fast-prime-number-generation-in-clojure
01:11wenshanIt has an equivalent python version, which returns a generator (infinite)
01:11TEttinger,(defn prime? [n] (.isProbablePrime (BigInteger/valueOf n) 5))
01:11clojurebot#'sandbox/prime?
01:12TEttinger,(take-while #(< % 1000) (filter prime? (range)))
01:12clojurebot(2 3 5 7 11 ...)
01:12TEttinger,(count (take-while #(< % 1000) (filter prime? (range))))
01:12clojurebot168
01:13TEttingerso there are 168 probably primes under 1000, sound right?
01:13TEttinger*probable primes
01:15TEttinger,(last (filter #(.equals (str %) (apply str (rseq (str %)))) (take-while #(< % 1000) (filter prime? (range)))))
01:15clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Reversible>
01:15TEttinger,(last (filter #(.equals (str %) (apply str (reverse (str %)))) (take-while #(< % 1000) (filter prime? (range)))))
01:15clojurebot929
01:15TEttingerthere you go
01:15TEttingerclojure has to be the best language I know for this kind of development
01:16TEttinger(I don't even have a REPL open, and I can still solve the problem -- thanks clojurebot!)
01:17TEttinger,(take-while #(and (> 928 %) (< % 1000)) (filter prime? (range)))
01:18clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: prime? in this context, compiling:(NO_SOURCE_PATH:0:0)>
01:18TEttingerhaha it unloaded it
01:18TEttinger,(defn prime? [n] (.isProbablePrime (BigInteger/valueOf n) 5))
01:18clojurebot#'sandbox/prime?
01:18TEttinger,(take-while #(and (> 928 %) (< % 1000)) (filter prime? (range)))
01:18clojurebot(2 3 5 7 11 ...)
01:18TEttinger,(take-while #(and (> % 928) (< % 1000)) (filter prime? (range)))
01:18clojurebot()
01:19TEttinger,(take-while #(and (> % 900) (< % 1000)) (filter prime? (range)))
01:19clojurebot()
01:19TEttingerhm
01:22TEttingerand to verify,
01:22TEttinger,(clojure.string/join " " (second (split-with #(< % 920) (take-while #(< % 1000) (filter prime? (range))))))
01:22clojurebot"929 937 941 947 953 967 971 977 983 991 997"
01:23TEttingerwenshan, do you have the gist of it now?
01:31Aaln(println "hello everyone")
01:31TEttinger,(Integer/toString (last (filter #(.equals (Integer/toString % 36) (apply str (reverse (Integer/toString % 36)))) (take-while #(< % 1000) (filter #(.isProbablePrime (BigInteger/valueOf %) 5) (range))))) 36)
01:31clojurebot"11"
01:31TEttingerthe last base 36 palindrome prime
01:31TEttingerunder 1000
01:32TEttinger,(Integer/toString (last (filter #(.equals (Integer/toString % 30) (apply str (reverse (Integer/toString % 30)))) (take-while #(< % 1000) (filter #(.isProbablePrime (BigInteger/valueOf %) 5) (range))))) 30)
01:32clojurebot"131"
01:32TEttingerneat
01:32Aaln,(Integer/toString (last (filter #(.equals (Integer/toString % 30) (apply str (reverse (Integer/toString % 30)))) (take-while #(< % 1000) (filter #(.isProbablePrime (BigInteger/valueOf %) 5) (range))))) 30)
01:32clojurebot"131"
01:32TEttingerhey Aaln
01:32Aaln.(println "hello world")
01:32Aaln,(println "hello world")
01:32clojurebothello world\n
01:32Aalnhey @Tettinger
01:32TEttingerhow goes?
01:33AalnPretty good, working on a clojure app atm
01:33AalnWhat's going on with you?
01:34TEttingerjust fiddling with clojure while I wait for mono to compile
01:34AalnWhat is 'mono'?
01:34TEttingerit's an implementation of MS .NET libs (and stuff like C#) for other platforms than windows
01:35TEttingerClojureCLR can run on it, not just C# by a long shot. I'm trying to get my C# code that uses a Java lib to work on linux
01:35AalnSo .net can compile to *** language?
01:36TEttingerno, .NET is just the platform (VM)
01:36TEttinger.NET is actually microsoft's one for windows
01:36TEttingermono doesn't do everything .NET does, but it runs almost everywhere
01:37TEttingerjava and clojure have an edge though because they are easier to get working on android, I would say
01:37AalnNot understanding... Does mono allow you to use .NET on other platforms asides from windows?
01:37TEttingeryes
01:37TEttingerand .NET is what C# runs on
01:37AalnAwesome
01:38TEttingerit would be if it worked!
01:38Aalnlol
01:38AalnHave you used to clojure for android?
01:59wenshanTEttinger:Thanks a lot, the isProbablePrime thing looks elegant here. Why did you choose 5 as certainty?
02:00TEttingerthat's what it had in the stack overflow answer, tbh
02:00TEttingeryou can probably go lower for under 1000 numbers
02:01wenshanI see
02:01wenshanthis is really great
02:01TEttingeractually let's check now!
02:02TEttinger,(count (take-while #(< % 1000) (filter #(.isProbablePrime (BigInteger/valueOf %) 5) (range))))
02:02clojurebot168
02:02TEttinger,(count (take-while #(< % 1000) (filter #(.isProbablePrime (BigInteger/valueOf %) 2) (range))))
02:02clojurebot169
02:02TEttingerah!
02:03TEttingerlower certainties may result in false positives, but 2 is really low
02:03TEttinger,(count (take-while #(< % 1000) (filter #(.isProbablePrime (BigInteger/valueOf %) 9) (range))))
02:03clojurebot168
02:03TEttingerso we can be fairly sure there are 168 primes under 1000
02:03wenshanmakes sense
02:05TEttinger,(clojure.set/difference (set (take-while #(< % 1000) (filter #(.isProbablePrime (BigInteger/valueOf %) 2) (range)))) (set (take-while #(< % 1000) (filter #(.isProbablePrime (BigInteger/valueOf %) 5) (range)))))
02:05clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.set>
02:06TEttinger,(require clojure.set)
02:06clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>
02:06TEttinger,(require 'clojure.set)
02:06clojurebot#<SecurityException java.lang.SecurityException: denied>
02:31wenshanTEttinger: I can understand the logic (have some emacs-lisp background), but the hash symbols used in #(.equals ...) and (take-while #(< % 1000) ...) are something new. What I found on stackoverflow says it's a reader macro that expands to (var foo). Am I reading the correct thread?
02:32TEttingerno, not quite. # is a special part of a reader macro that is used for a lot of purposes
02:32TEttingerhere, it's lambdas
02:32TEttinger,(map inc [1 2 3])
02:32clojurebot(2 3 4)
02:32TEttinger,(map #(+ % 1) [1 2 3])
02:32clojurebot(2 3 4)
02:33TEttingerso #() is a lambda that takes args by number, like %1, %2, %3, and % (with no number)is an alias for %1
02:33TEttinger,(map (fn [n] (+ n 1)) [1 2 3]) equivalent to this
02:34clojurebot(2 3 4)
02:34wenshanI'm trying to understand it in elisp, I guess it's equivalent to (mapcar (lambda (x) (+ x 1)) '(1 2 3))
02:34TEttingerbut if you see # elsewhere it depends on what's after it.
02:35TEttinger,(map inc #{1 2 3})
02:35clojurebot(2 4 3)
02:35TEttinger#{} is a set
02:35TEttingerunsorted, but checks for uniqueness
02:35wenshanhmm, I see
02:35TEttingerand yes, i think you're right about the elisp
02:36TEttinger#' is what you mentioned about vars
02:36TEttinger,#'inc
02:36clojurebot#'clojure.core/inc
02:36wenshan#() is really handy, I like it
02:36luxbockhttp://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/
02:36TEttingerit's great for one-liners, it's why clojure is one of the best lisps for short programs
02:36luxbockthis is a good resource
02:37wenshanthanks :D
02:39TEttingerwow, that's really handy luxbock
02:39TEttingerI forgot about the #"" regexps, though I use them plenty
02:54TEttinger(inc luxbock)
02:54lazybot⇒ 1
02:54luxbockyay
02:55luxbockinternet points
02:55TEttingerclojurebot: symbols |are| http://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/
02:55clojurebotRoger.
02:56TEttingersymbols?
02:56clojurebotsymbols are http://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/
02:56TEttingerhm, symbols are also a type
02:56TEttingerclojurebot: unlearn symbols |are| http://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/
02:56clojurebotIn Ordnung
02:56TEttingersymbols?
02:56clojurebothttp://clojure.org/data_structures#toc10
02:57TEttingerclojurebot: punctuation |means| http://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/
02:57clojurebot'Sea, mhuise.
02:57TEttingerpunctuation?
02:57clojurebotpunctuation means kind of fun
02:57TEttingerpunctuation?
02:57clojurebotpunctuation is preferred to a torrent of newlines
02:57TEttingerpunctuation?
02:57clojurebotpunctuation means unlearn symbols
02:57TEttingergah
02:58TEttingerclojurebot: punctuation |is| http://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/
02:58TEttingerpunctuation?
02:59TEttingerclojurebot: forget symbols are http://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/
06:35rurumatein storm-starter I've managed to start an nrepl connection on 4005 using 'mvn clojure:nrepl'. Now in emacs / cider I can connect to repl, and reload the word_count namespace, but jump-to-definition M-. doesn't work. Emacs says "unknown resource path". Any ideas?
08:35at21Hi guys. How to install clojure libraries from clojars (for example https://clojars.org/ring) ?
08:35at21I have leiningen installed successfully
08:37at21Hi guys. How to install clojure libraries from clojars (for example https://clojars.org/ring) ? I have leiningen installed successfully
08:38boxedat21: in project.clj under :dependencies put [thelib “version”] and then run lein
08:38boxedif you can’t get it to work, put the project.clj on a pastebin and put in the link here
08:40at21M-m, thank you. I'll try it
08:48at21boxed: Now what? I've just put the library I want into project.clj in .lein/ directory
08:49jkjat21: profiles.clj ?
08:49at21oh, yeap
08:49at21profiles...
08:50boxednono, the project.clj file in your own project
08:53at21ok, If I put it in my project file what about other projects?
08:53at21and what if I want to use it in REPL?
08:53boxedyou should add dependencies for a project in that project…
08:54boxedif you do “lein repl” in the same folder as a project.clj you’ll get the dependencies
08:54at21Isn't there anything like in python where you just install some package via PIP and you can use it anywhere by importing it?
08:55boxedyou probably can.. but that is one of the worst things about python so why would you want to? :P
08:55at21))
08:55at21why is that?
08:55boxedI say this as a full time python code :P
08:55at21because it doesn't isolate things?
08:55boxedbecause then you move some code to another machine and it explodes
08:55boxedyea exactly
08:56at21"""if you do “lein repl” in the same folder as a project.clj you’ll get the dependencies""" Okay, how am I gonna get them? They will be downloaded right?
08:58boxedyea
08:58boxedand it checks that they’re signed properly etc
08:59at21Okay, say there are downloaded. What if I want to use them in other project, but I don't have the internet connection. Wouldn't that be a problem? I mean I don't often have an internet
08:59Glenjamindependencies are cached locally
09:00Glenjaminjust not in a place they can be depended on implicitly :)
09:00boxedto be more precise: they are downloaded to a central place on your computer if they aren’t already in that central place
09:02at21don't get it). So I can't store them to further use?
09:03Glenjaminthey get downloaded to ~/.m2
09:03at21great
09:03at21that's what i've been asking
09:04at21so that means I can use them whenever I want without the internet (if they are downloaded already) by just pointing it in :dependencies?
09:05Glenjaminyes
09:05at21Oh, great. Big thanks to <boxed> and <Glendjamin>
09:06boxednp
09:19daGrevishi! i know there's lein repl. is there anything more advanced with syntax highlight and auto-complete?
09:24justin_smithdaGrevis: cider for emacs and fireplace for vim aim at that, light table has its own editor integrated version of things, as does cursive (an intellij idea plugin)
09:25daGrevisjustin_smith, but is there anything that's editor agnostic?
09:28daGrevisand another question if I may. i have a data-structure and i want to get a random element from it do something with it and return it from my function. how do i do that?
09:29daGrevisi mean exactly... i can't create a temporary variable and store things i will return later
09:29daGrevisi can't find anything like yield in python too so that's out
09:30nathan7daGrevis: .WHAT DO YOU MEAN?
09:30nathan7err
09:30nathan7sorry for caps
09:30nathan7daGrevis: (let [x (inc y)] ...)
09:31nathan7daGrevis: tahdah, temp variable
09:31daGrevishmm how could i explain it better without you doing in my place :D
09:31nathan7daGrevis: `let` creates local variables
09:31daGrevisnathan7, right, but i can't change it no?
09:31nathan7Correct, but you can make new things based on it
09:31nathan7(let [x (inc x)] …)
09:31nathan7that's basically x += 1
09:32daGrevishttps://gist.github.com/e17730a0d1c4bee11718
09:33nathan7Try `for` instead of dotimes
09:33nathan7and no need to turn chain into a seq beforehand, by the way
09:33daGrevisright list comp!
09:34daGrevisnathan7, chain's a map
09:34nathan7daGrevis: rand-nth should turn it into a seq by itself I think?
09:34daGrevisrand-nth won't work on map, only seq
09:34Glenjamin$source rand-nth
09:34lazybotrand-nth is http://is.gd/HVnhk6
09:34nathan7,(rand-nth {:a :b})
09:34clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap>
09:34nathan7:(
09:34daGrevistold ya :)
09:34nathan7silly
09:34Glenjaminit does this: (nth coll (rand-int (count coll))))
09:34nathan7yeah
09:35Glenjaminwhich makes a whole bunch of assumptions
09:35nathan7mhm
09:35nathan7yay dynamic typing
09:35daGrevis:)
09:39daGrevisi'm not sure for will be the best solution there
09:40daGrevisbasically i have markov chain in format of {:word [:following :words] :word2 [...]}
09:40daGrevisand i want to choose key, then choose value of that key and repeat it 2 to 5 times
09:42Glenjaminsomething like (mapcat #(random-sample (val %)) (random-sample words))
09:42daGrevisi'll just try recur it
10:16daGrevisi wrote what i wanted
10:16daGrevisit is so ugly :)
10:26justin_smithdaGrevis: you may be able to express that in terms of iterate
10:27daGrevisjustin_smith, https://gist.github.com/595f08e9b6612d1b5405
10:27daGrevisi expressed it already
10:27daGrevisit's just fugly for now
10:27justin_smithand, regarding editor agnostic, no, I don't know of any tool that adds highlighting and completion to the repl that is not part of some editor
10:28daGrevistoo bad. i didn't fell in love with vim-fireplace(
10:29justin_smithdaGrevis: I mean you can simplify that loop you have to be in terms of iterate
10:29justin_smithbecause it is an iterate shaped problem
10:30daGrevisi will look into it, but i don't see how it's possible by simply iterating through map
10:30justin_smith,(take 5 (iterate #(conj % (rand-int 10)) []))
10:30clojurebot([] [0] [0 3] [0 3 0] [0 3 0 1])
10:30justin_smiththat is not what iterate is
10:30justin_smithit doesn't "iterate through" anything
10:30justin_smithit repeatedly takes some action to build a result
10:31justin_smithalso, depending on the length of the sequence you are building, pop will be much faster than last
10:32daGrevisok i will look into iterate. sorry about not knowing what iterate is -- i'm new to this :)
10:32justin_smithand though (seq chain) is not redundant, (seq next-words) is
10:33daGrevisright, thanks
10:33justin_smithno need to apologize for not knowing, though assuming you know despite someone more experienced suggests it could be useful is likely to lead to wasting your own time :)
10:34daGrevisright. ok let me try with iterate
10:36boxeddeGrevis: how does the input look?
10:36daGrevisiterate is something like generator
10:36daGrevisif i understand correctly
10:37daGrevisboxed, https://gist.github.com/41dbe86764e19228bc32
10:37justin_smithdaGrevis: my version, untested because I don't have the chain map
10:37justin_smithhttps://www.refheap.com/88388
10:37boxedthat’s a bit too vague for me to say anything :P
10:38justin_smithboxed: he has mentioned this before, it is a simplistic markov chain representation, keys are preceding words, vals are a seq of following words
10:38boxeddaGrevis: I used a lot of core.match for making sense of not-super-nice datastructures, have you looked at that?
10:39boxedah
10:40daGrevishere's better data set https://gist.github.com/94ec78b417a40c567d05
10:41daGrevisnot much better thought :)
10:42daGrevisjustin_smith, it throws exception about not being able to pop empty vector
10:43justin_smithyeah
10:43justin_smithworking on that :)
10:43justin_smithalso needs a nil check for words
10:44justin_smithalso calling last on iterate is a bad idea
10:44daGreviskeys can't be nil
10:44justin_smithright, and without a nil check, it loops forever
10:56daGrevisi don't get why you are passing [] to iterate not chain
10:57justin_smithiterate needs an initial value
10:58justin_smithand the value is what is built up over the calls
10:58daGrevisoh
10:59daGrevisright it makes sense now
10:59justin_smithstill a couple of things I need to sort out with that though
11:03daGreviswhy did you call last on lazy seq if result from function should be a vector with words?
11:03justin_smith,(take 5 (iterate #(conj % (rand-int 10)) []))
11:03clojurebot([] [2] [2 6] [2 6 1] [2 6 1 7])
11:04justin_smith,(last (take 5 (iterate #(conj % (rand-int 10)) [])))
11:04clojurebot[6 9 4 5]
11:04daGrevisright
11:05justin_smithdaGrevis: works now https://www.refheap.com/88388
11:05daGrevisthis is a very interesting way to solve this problem
11:05justin_smithI was using pop when I meant peek, d'oh
11:06daGrevisworks for sure, thanks
11:06daGrevisnow i gotta learn what you know already :D
11:07boxedmy version: https://www.refheap.com/88389
11:08justin_smith,((fn [c] (last (take-while #(not (nil? (peek %))) (iterate (fn [w] (let [s (peek w) n (rand-nth (get c s))] (conj w n))) [(first (rand-nth (seq c)))])))) {"hello" ["world" "my"] "my" ["baby" "darling"] "baby" ["hello"]})
11:08clojurebot["baby" "hello" "world"]
11:08justin_smith,((fn [c] (last (take-while #(not (nil? (peek %))) (iterate (fn [w] (let [s (peek w) n (rand-nth (get c s))] (conj w n))) [(first (rand-nth (seq c)))])))) {"hello" ["world" "my"] "my" ["baby" "darling"] "baby" ["hello"]})
11:08clojurebot["baby" "hello" "world"]
11:08justin_smith,((fn [c] (last (take-while #(not (nil? (peek %))) (iterate (fn [w] (let [s (peek w) n (rand-nth (get c s))] (conj w n))) [(first (rand-nth (seq c)))])))) {"hello" ["world" "my"] "my" ["baby" "darling"] "baby" ["hello"]})
11:08clojurebot["baby" "hello" "my" "baby" "hello" ...]
11:08boxedassuming I understand what we’re doing, which is a pretty big assumption :P
11:08justin_smith,((fn [c] (last (take-while #(not (nil? (peek %))) (iterate (fn [w] (let [s (peek w) n (rand-nth (get c s))] (conj w n))) [(first (rand-nth (seq c)))])))) {"hello" ["world" "my"] "my" ["baby" "darling"] "baby" ["hello"]})
11:08clojurebot["baby" "hello" "world"]
11:08justin_smith,((fn [c] (last (take-while #(not (nil? (peek %))) (iterate (fn [w] (let [s (peek w) n (rand-nth (get c s))] (conj w n))) [(first (rand-nth (seq c)))])))) {"hello" ["world" "my"] "my" ["baby" "darling"] "baby" ["hello"]})
11:08clojurebot["hello" "world"]
11:08justin_smith,((fn [c] (last (take-while #(not (nil? (peek %))) (iterate (fn [w] (let [s (peek w) n (rand-nth (get c s))] (conj w n))) [(first (rand-nth (seq c)))])))) {"hello" ["world" "my"] "my" ["baby" "darling"] "baby" ["hello"]})
11:08clojurebot["baby" "hello" "my" "baby" "hello" ...]
11:08justin_smithanyway, sorry for the spam
11:09daGrevishmm i start to see the idea
11:09boxedwhy would you need to check for nil?
11:09daGreviswe pass first word that random as iterate's 2nd arg so we can get rid from special case that's the first iteration
11:10justin_smithboxed: because nil leads to an infinite sequence of nils
11:10justin_smithit is the only stop condition in my version
11:10boxedbut there’s no nil in the input data… right?
11:10justin_smith(that is a word with no following words)
11:10daGrevisboxed, thanks! i will look into it as soon as i will understand justin_smith's version
11:10justin_smithboxed: right, but you can have a word that is not an index
11:10justin_smiththat gets nil when looked up
11:10boxedaha, gotcha
11:10daGrevisi got it too :D
11:11justin_smithnot all words are indexed, in fact, in normal markov-chain lingo, a word that is not a key in the chain map is called a stop word
11:11daGrevistil
11:12justin_smithsince it has no possible following word
11:12justin_smithit only exists as an end of statement
11:12justin_smiththough, with a more advanced implementation, you can record "." to end a sentence as its own token, and then just never follow up after you reach "."
11:13justin_smithwhich allows more flexibility (a word has a certain probability of being a stop word this way)
11:13boxedfixed the nil problem: https://www.refheap.com/88389
11:13daGrevisi wonder what's the best way to stop “loop“ if there's no stop word. you see, i'm building sentences and i don't want sentences that are very long
11:14boxeddaGrevis: I have an input param that is a max length
11:14justin_smithwell, as I mentioned, you could record end of sentence specially (nil works as well as "." for that, and just stop recurring if you hit that.
11:14justin_smith)
11:14boxednice example of using loop-recur this… I managed to get it right on the first try and I’ve never managed to use loop-recur before :P
11:14daGrevisyes, i fully understand justin_smith's one:)
11:15justin_smiththen you get statements that are probabalistically in the range of the length of input statements
11:15daGrevisjustin_smith, i will have to do that:)
11:16boxeddaGrevis: I think mine is a bit simpler to understand… I don’t need two anonymous functions :P
11:19daGrevisim trying to understand it now. give me some time
11:21daGrevisaha, i got it
11:21daGrevisit reminds me of my version i did before https://gist.github.com/5233a7e836f15be227a5
11:23justin_smithhttps://www.refheap.com/88388 updated mine with a less verbose version
11:23justin_smithnot sure if it is more clear though
11:26justin_smithoh wait, since false is not a valid token in the chain, I can make it much simpler https://www.refheap.com/88388
11:26justin_smithnow only one anon fn
11:28daGrevishere's another my version https://gist.github.com/0de0a4aca40ea10b8edf
11:30daGrevisremoved lets that were not really needed
11:30daGrevishttps://gist.github.com/d466e39235df87d6d49f
11:30daGreviswhat do you think?
11:32boxedis it normal to call the data structure that describes all possible chains “chain”? seems weird.. a chain seems like the output: a list
11:32boxedof course “foo” isn’t super good like in my example code either but still :P
11:34daGreviswell i saw that map like a markov chain because it contains all possible words that may come next and i saw that list like words because it's basically list of words that will make up the sentence and it's no longer a chain because it doesn't have path to next words
11:36boxeda chain is a list of connected metal rings… I think the analogy that [1 2 3] is a chain is pretty solid :P
11:37boxed“sentense” and “word” are specific to this perticular application of markov chains, but not general terms.. so if you use this code for another type of chain generation it’d be very strange
11:38boxedI’ve edited my version to use “next-item” as variable name, I think that makes a lot more sense: https://www.refheap.com/88389
11:39daGrevisif we call that list a chain
11:40daGrevishow do we call map?
11:40boxedwikipedia wasn’t much help… I don’t like “stochastic-row-vector” for the map :P
11:40boxedI think “state-transitions” is ok?
11:40boxedbetter than “foo”… actually, even “chains” is pretty ok, because it describes all possible chains
11:41boxedlike this: https://www.refheap.com/88389
11:42boxedchanged the funtion to take the state transition map as input, makes more sense
11:43boxedanyway… I’m going for dinner, hope this has helped, I know it has helped me with loop/recur :P
11:56sm0kehello anyone tried play-clj here?
11:57sm0kehow do i relaunch the game without crashing lein?
11:57sm0kerepl*
13:09troutwineHi folks, would this be the appropriate channel to ask about emacs setup problems with cider?
13:13ybittroutwine: maybe, but the #emacs channel is active
13:13ybitmore so than this one ..on the weekends :)
13:14troutwineybit: Haha, alright. I'll head there. Thanks.
13:14jeremyheilerthere's also #clojure-emacs
13:14troutwineOh, that sounds dead-on.
14:14andyfBronsa: Any reason I should avoid trying out the latest t.a(.jvm) for Eastwood? You mentioned there was some performance regression in a recent version, but I haven't been following to see if that has been improved.
14:17Bronsaandyf: there are a bunch of breaking changes in master that I have yet to document on the CHANGELOG
14:18andyfBronsa: Are there breaking changes in 0.3.0 release relative to 0.2.2 that you recall?
14:18Bronsaandyf: yes but a minor one, :contexts are now namespaced
14:19Bronsai.e. :statement -> :ctx/statement
14:20andyfDoes :statement there mean :statements as in that key in the AST of do expressions? If not that, then I might not be using it in Eastwood anyway right now.
14:20Bronsaandyf: also they now implement a hierarchy so it's wise to replace (= ctx :expr) with (isa? ctx :ctx/expr)
14:21Bronsaandyf: no it's one of the analysis contexts in :env
14:21andyfI'll give 0.3.0 a try and see if anything breaks :)
14:21Bronsaif you're not using it then nothing should break
14:22Bronsaandyf: the performance fix is in 0.3.1-SNAPSHOT, the regression affects 0.2.2, 0.2.3 and 0.3.0
14:22andyfI'll measure performance to see if it is anything terribly different than previous Eastwood release
14:23Bronsaandyf: not too sure how much it inpacts eastwood but I saw a ~1.5x slowdown in t.e.jvm
15:01boxedupdate-in not supporting [] as path makes me sad :(
15:04boxedand this makes me even more sad: http://dev.clojure.org/jira/browse/CLJ-373
15:04dbaschboxed: what would you expect [] to do?
15:06boxeddbasch: without looking it up, can you tell me what you expect for: (update-in {:foo 1} [] #(dissoc % :foo))
15:07dbaschboxed: it seems you’d want update, which doesn’t exist
15:07sritchiehey technomancy, I was looking at this article: https://devcenter.heroku.com/articles/debugging-clojure
15:07sritchietechnomancy: and with lein repl :connect to an endpoint that uses http basic auth,
15:08sritchieit looks like you have to type the password into that string -
15:08sritchietechnomancy: what would you think of having “lein repl :connect” prompt for a password if only a username is supplied, like curl?
15:08justin_smithdaGrevis: boxed: I realized there was another redundancy in my iterate version, I like the latest version a lot https://www.refheap.com/88388 (now updated with no anonymous functions, and some example output)
15:09boxeddbasch: I don’t know ahead of time how long that path is… so now I have to add an extra if that breaks the symmetry :(
15:10nonrecursive_hi all - I'm using Emacs and trying to get eldoc working in a clojure-mode buffer after having connected to nrepl with cider-repl
15:11boxedjustin_smith: hmm… I’m too unused to functional composition for my brain to parse that :(
15:11nonrecursive_it seemed like this work with with cider 0.5 (i'm on a 0.7 snapshot now)
15:11justin_smithboxed: total hack version: (update-in [nested] (concat [0] lookup) ...)
15:11justin_smiththus the sequence is always at least of length 1
15:12justin_smith(because of the added layer of vector, of course)
15:12boxedhah, blech
15:12boxedI think I’ll go with the if :P
15:13boxedjustin_smith: but yea, that assymetry in that hack shows why empty path should be supported
15:13justin_smithyeah, I also think it should be supported
15:14boxedat least it’s Principle of Least Surprise
15:17justin_smithboxed: I think in the clojure world, lower complexity of implementation often trumps least surprise
15:18boxed…so a lisp on top of java on top of a JVM favors simplicity of implementation? :P
15:18justin_smiththere is no java layer
15:18justin_smithclojure is straight to jvm
15:18justin_smith(with some aspects implemented in java, but the java is not a layer per se)
15:19boxedno java? https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Binding.java <- java!
15:19boxedbut yea ok, if you ignore the java there is no java :P
15:20justin_smithit's not a layer
15:20boxedit’s complexity of implementation
15:20justin_smithsome of the code is java, others is bootstrapped clojure
15:20boxedanyhow, clojure is clearly built on a mountain of complexity.. but I do understand that Wose is Better
15:20boxedWorse even
15:21justin_smithI didn't say the implementation was free of complexity, I said that often, the principle of least surprise is often trumped by ease of implementation
15:21boxedin this case though, we don’t know what trumped what.. there was a patch, then the issue was closed without ceremony :(
15:22sritchietechnomancy: filed an issue on reply, looks like that’s the place where this change would need to occur
15:26dbaschboxed: you’re conflating simplicity of implementation IN the language with simplicity of implementation OF the language
15:27dbaschevery technology that’s easy to use has a ridiculously complicated implementation based on geological layers accumulated over decades of technology advances
15:27boxeddbasch: oookey… but implementation IN the language becomes complex because update-in doesn’t handle [], but the implementation OF the language is simpler. So maybe you’re conflating?
15:27dbaschboxed: nobody said implementation OF the language is simple, you are the one who brought up java and the jvm
15:28boxedjustin_smith said that the simplicity of implementaton of the language trumps least surprise/correctness
15:28boxed...sometimes
15:29dbaschboxed: and update-in does handle [], just not in the way you’d like
15:29Jaoodjustin_smith: there's a java layer for sure, all clojure primitive building blocks are written in Java
15:29boxeddbasch: cop out. Everything “handles” everything if by “handles” you also accept behavior no one ever wants that is totally broken
15:34justin_smithJaood: clojure has a byte code emitter, it compiles without a java step
15:35boxedand there’s at least been some work to bootstrap those primitives I believe
15:36justin_smiththere are at least a couple of pure-clojure-on-jvm type projects in the works
15:36justin_smith(with different goals)
15:43boxednew version of instar that has a special little syntax for dissoc! https://github.com/boxed/instar
15:44boxedit’s like update-in on crack™
15:44AeroNotixdoes anyone know if core.clj has ever been ported to common lisp?
15:49justin_smithAeroNotix: no, but racket scheme has most of the clojure features of clojure, and there are various libs that close the gaps
15:49justin_smithby no I mean "I don't know of any", there may be one
15:49AeroNotixjustin_smith: "various libs" -- for racket you mean?
15:49justin_smithyeah, to do things like the -> macro
15:49AeroNotix(I'm not really interested in racket (unless you can convince me!))
15:50justin_smithracket already has immutible collections
15:50AeroNotixSo does CL
15:50AeroNotix~mostly
15:50clojurebotTitim gan éirí ort.
15:50justin_smithit's well designed, and great as a teaching / learning language
15:50AeroNotixIt could well be
15:51justin_smithbut it isn't an implementation of a standard like common lisp though
15:51AeroNotixsure
15:51AeroNotixTBH I just want to use Clojure with SBCL
15:51justin_smithalso, lisp-1, which for some people is a bonus
15:51AeroNotix :)
15:51justin_smithbut I know if you like cl enough, you probably don't see lisp-1 as an advantage
15:51AeroNotixlisp1 > lisp2
15:52AeroNotixI just put up with it in CL
15:53ad_latebrasjustin_smith
15:53ad_latebraswhat is your opinion on this whole PC gaming master race thing.
15:53AeroNotixBut back to my main point -- there's tonnes I miss from Clojure in CL and vice versa
15:54justin_smithad_latebras: I have know idea what you are talking about
15:54technomancysupposedly racket's continuations can be used to build something like CL's condition system
15:54ad_latebrasjustin_smith, well, the idea is that PC gamers are genetically superior to console gamers.
15:54ad_latebrasWould you agree?
15:54justin_smithtechnomancy: continuations are capable of implementing just about anything
15:55technomancyad_latebras: please don't
15:55ad_latebrastechnomancy?
15:55clojurebottechnomancy is <jweiss> oh man this sucks, why didn't anyone warn me about protocols
15:55AeroNotix+b
15:56AeroNotixtechnomancy: I don't find I genuinely use conditions all that much. I feel they really shine in a live system that has a human attached to it 24/7
15:56AeroNotixbut that's just like my opinion, man
15:56mi6x3mhow would clojure count character occurences for 1 spefic char?
15:56mi6x3mreduce or (count (re-seq ?
15:56justin_smithmi6x3m: frequencies
15:56technomancyad_latebras: it would be cool if we didn't have to kickban; that's all
15:57mi6x3mjustin_smith: I need only 1 of the frequencies :)
15:57AeroNotixmi6x3m: it's the most obvious way to write it
15:57justin_smith,(get (frequencies "hello world") \l)
15:57clojurebot3
15:57justin_smithmi6x3m: well, there is always reduce for that, yeah
15:58mi6x3mgood argument, most obvious :)
15:58mi6x3m(inc AeroNotix)
15:58lazybot⇒ 4
15:58gfredericks,(->> "hello world" (filter #{\l}) (count))
15:58mi6x3mthanks!
15:58clojurebot3
15:58mi6x3mah, sets were functions yes
15:58mi6x3mI always forget
15:59gfredericksreduce is too general for that :)
15:59ad_latebrastechnomancy, what did I do?
15:59justin_smithgfredericks: yeah, I'd say frequencies if there is no bottleneck, filter/count if you need to get a few more cycles, and finally reduce if the collection is just too big (ie. counting the letter e instances in the kjv)
16:01gfredericksjustin_smith: I'm sympathetic to the argument about frequencies doing too much
16:01gfrederickseven if in cases where it doesn't make a perf difference
16:01gfredericksnot sure I could make a coherent argument about it though
16:02AeroNotixgfredericks: it's less typing
16:02AeroNotixclick
16:02gfredericksAeroNotix: I'm more interested in what I have to think about when reading the code than how many characters there are
16:02AeroNotixgfredericks: was kind of a joke :)
16:03justin_smithgfredericks: by the same logic, #{\l} does a bunch of things #(= % \l) doesn't, and they are redundant in this case
16:03gfredericksjustin_smith: implementationally, sure, I'm thinking semantically
16:03gfredericksbut I agree #{\l} is a bit complicated
16:04gfredericksI think it'd be nice if there were something else
16:05gfredericksagain I must emphasize my inability to guarantee coherence here
16:06AeroNotixgfredericks: I'm sure there's enough use-cases behind having an (occurances thing coll) function in core
16:07gfredericksoh I forgot I need to not argue about what should go in core
16:14technomancyad___latebras: in the past when new people come in and make unsolicited faux-racism remarks to channel regulars it hasn't ended well... merely pattern recognition.
16:14ad___latebrastechnomancy, oh, o
16:14ad___latebrasThis is not racism.
16:14ad___latebrasIn fact
16:14ad___latebrasthe glorious PC gaming master race is portrayed as a brown man.
16:15ad___latebrasAnd the dirty console peasant as a white man
16:15ad___latebrasprobably to distance itself from the connotations of racism
16:15ad___latebrastechnomancy, look: http://segabits.com/wp-content/uploads/2014/04/iconurl.png
16:16AeroNotixcan we just ban this troll
16:16AeroNotixit's boring
16:17technomancyAeroNotix: amazing how effective simple pattern recognition can be
16:22guestChi
16:22guestCanybody alive here?
16:23AeroNotixof course
16:26guestCcan anybody explain how does this work?
16:26guestC(defn positive-numbers ([] (positive-numbers 1)) ([n] (cons n (lazy-seq (positive-numbers (inc n))))))
16:26guestChow can the function exist without parameter vector following its identifier?
16:26AeroNotixguestC: multiple function arities
16:27guestCis that a thing?
16:27AeroNotixthat's a thing
16:27guestCok thank you :)
16:27guestCone more thing
16:27AeroNotixgfi
16:28guestChow would you go about designing stream consumption? lets say i have stream of data coming irregulary and i need to feed it to a function one element after another.. custom lazy sequence?
16:28AeroNotixguestC: take a look at core.async
16:30guestCis that part of the core?
16:30augustlis there any way for cider to auto-detect the port of which a repl is running so I don't have to type in the port number?
16:32jeremyheileraugustl: it does that with .nrepl-port, i believe
16:36guestCAeroNotix: I would have to import something to use core.async right? But in general what you are saying is I should use concurrency, right?
16:36AeroNotixguestC: it's an extra library, you should be using leiningen
16:36AeroNotixguestC: it *sounds* like you should use concurrency, but you didn't really explain fully
16:37jeremyheileraugustl: https://github.com/clojure-emacs/cider/blob/master/nrepl-client.el#L979
16:37guestCAeroNotix: in java i would be using blocking queue.. not sure how to get that in clojure.. idiomatically
16:38AeroNotixguestC: core.async has channels. Go learn about them
16:38AeroNotixIt's kind of like a blocking queue, except a bit different
16:38guestCAeroNotix: ok, thanks for directions ;)
16:38AeroNotixguestC: not a problem
16:38justin_smithAeroNotix: it uses some queues under the hood, but has its own flavor of abstraction over using them
16:39AeroNotixjustin_smith: sure, I was intentionally vague in my description so they would go learn
16:43augustljeremyheiler: ah, I see
16:54gfredericksguestC: lazy seqs aren't a bad way to do it if you can get away with it
16:54guestCi will try that for easy solution before i study upon the async library
17:18gfredericksokay let's pretend I wrote this: https://www.refheap.com/88401
17:18gfrederickswhich I did
17:18gfredericksshould I have just used clojure.core/locking?
17:22justin_smithwell the advantage of an agent is that clojure ensures the sequential state. With locking you need everyone to lock on the same thing if they touch that data. So with a narrow scope of the data, you could simplify things by using locking, but if the data escapes scope, locking is too weak
17:23justin_smithIMO at least
17:25gfredericksthe agent doesn't have any data
17:25gfredericksit's just used for locking
17:25amalloygfredericks: there's at least one race condition in that code, right?
17:26amalloyor wait, you're derefing the promise, not the agent
17:26gfredericksamalloy: not that I kow of
17:26gfrederickscow*
17:27amalloyyeah, i don't see what this is buying you over locking
17:28gfrederickscool that's what I was thinking
17:28gfredericksI did this because I assumed locking was evil
17:28amalloythis also introduces some weird issues, like what if someone calls serialize-on-agent from inside of a dosync, and their func is one that attempts to await-for another agent or something
17:29amalloyi don't know exactly what the failure case is, or even if there is one, but it seems dangerous
17:31amalloygfredericks: and sure, locking is problematic, but if your solution is to reinvent locking with different primitives what's the point
17:31gfredericksexactly
17:38pentlander how would i go about returning an item from a vector using a closure? for example you have a vec [1 2 3] and a func vec-item that would return 1 on the first call, 2 on the second call etc.
17:39brehaut~XY
17:39clojurebotGabh mo leithscéal?
17:41brehauthttp://mywiki.wooledge.org/XyProblem
17:41brehautpentlander: perhaps back up a bit and tell us the problem you are trying to solve rather than asking for the particular solution (because it doesnt sound like a very clojury thing to be doing)
17:42mthvedtpentlander: wrap up a java iterator, but you probably don’t want to do that
17:43platzproblem with the XYProblem - does it discourage one from trying to think though a problem? i.e. the initial question exactly is someone trying to exercise their problem solvin skills
17:44gfredericksthis is the XYProblemProblem
17:44platzotherwise you just get a post on stackoverflow saying, "please do this for me"
17:44brehautgfredericks: i think you need an XYProblemProblemAbstractFactoryFactory
17:44amalloyplatz: no, it's best to ask both the X and the Y
17:44brehautBean
17:45platzamalloy: hrm, that seems to make some sense
17:45amalloy"i want to do X, and i think Y is a good way to do that; how do i do Y?" demonstrates that you've made an effort, and helps the answerer understand your thinking, but doesn't leave them in a "wth why do you want a square wheel" situation like just asking Y would
17:45platzrequires an understanding of X though. someone may not even know "the problem they are trying to solve"
17:46pentlanderalright well the overall problem is that i have a vec of items ["a" "b" "c"] and i need to output each subsequent item after an event is triggered, so on the first trigger it returns "a" and on the second "b", etc
17:46platzbut I may be stretching a bit here
17:46gfrederickspentlander: what sort of events?
17:46pentlanderclick event
17:46amalloyplatz: just ask yourself "why?" four times in a row. isn't that some technique people use?
17:47platzI like your previous answer
17:47mthvedtit’s five whys
17:47mthvedtstudies have shown the critical number of whys is 5
17:47amalloymthvedt: why?
17:47amalloy(that was the fifth one there, see? it sneaks up on you)
17:47mthvedtamalloy: ask me four more times
17:48mthvedtasketh thou not six whys, nor shalt thou asketh four except that thou proceedeth to five
17:48gfrederickswhen you ask the fifth why first it kind of messes up the process
17:48gfredericksbest to ask them in order
17:55mthvedtcan i get a second pair of eyes to look over to the readme for this oss project, before it’s released to the world?
17:55mthvedthttps://github.com/mthvedt/qarth
17:59dbaschmthvedt: this method doesn’t do anything: https://github.com/mthvedt/qarth/blob/master/src/qarth/util.clj#L15
18:00mthvedtdbasch: good catch
18:00dbaschs/method/function of course
18:31vimuser2Hey there, can someone point me to the direction on how defrecord works? in particular, treating a record as a hash map and adding new fields…from my understanding defrecord creates a class and adds the fields under neath the hood, curious how it implements other fields then
18:32Bronsavimuser2: it stores them in an internal hashmap
18:32Bronsa,(defrecord x [a])
18:32clojurebotsandbox.x
18:32Bronsa(.__extmap (map->x {:a 1 :b 2 :c 3}))
18:33Bronsa,(.__extmap (map->x {:a 1 :b 2 :c 3}))
18:33clojurebot{:c 3, :b 2}
18:33vimuser2bronsa: ah, thats what i was guessing. thanks =)
18:51vimuser2Bronsa: ha, just found defmacro defrecord..lots of little tasty stuff in there =)
18:51vimuser2well, for a clojure newbie
19:46zoldarWas anyone able to use om 0.6.4 (or any post 0.5.0 for that matter) along with austin repl? there seems to be conflict in requirements for a particular clojurescript version.
20:15fifosinewhere can I find the source for the mult operator *?
20:16TEttingerfifosine, it's probably an RT function, as in implemented in Java or JS for Clojure or CLJS
20:16fifosineRT?
20:16TEttingerruntime
20:17TEttingerthis may be it, https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Numbers.java#L146
20:18TEttingerit gets more specific later on https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Numbers.java#L459
20:19TEttingerlike it has specific versions for doubles https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Numbers.java#L1379
20:21fifosinemm
20:49gfredericksI think the CLJS version is a lot simpler, just turning into JS multiplication
21:11hellofunkif I want to apply a sequence to a function, but also need a single additional arg passed to the fn after the sequence, is this really the best way: (apply + (concat (range 5) '(6))) Necessary in Om when the order matters since you are laying out HTML elements
21:16justin_smithwell, if the initial collection is a vector, you can at least use conj instead of concat
21:17justin_smith,(apply + (conj [0 1 2 3 4] 6))
21:17clojurebot16
21:17amalloyhellofunk: yes. or (apply + `(~@(range 5) 6)), but using ` ~ ~@ outside of macros isn't super-popular
21:17hellofunkjustin_smith good point though I'm not sure Om's build-all is a vector, I'd have to check
21:17justin_smithamalloy: that's effectively a concat though isn't it?
21:18amalloysure
21:18amalloybut it's shorter and can be more legible depending on context
21:30gfredericksit's shorter and can be more frightening depending on context
22:13cj3kim_Hi. I'm tired of using light table for Clojure. Anyone have recommendations on what they use as their IDE?
22:14caterncj3kim_: emacs
22:14justin_smithfor an IDE I hear good things about cursive for intellij idea
22:15cj3kim_emacs sounds good any recommended guides? is onboarding easy?
22:15justin_smithI think learning emacs and clojure at the same time would be a bit rough, but if you already know clojure, emacs may be worth a try
22:16justin_smithit comes with a built in tutorial / docs, but it is ancient, so many things are harder than they would otherwise be because other programs gave different names to things that emacs invented (ie. windows in emacs are frames in modern programs, frames in emacs are windows in modern programs...)
22:16radioactiveoctophmm i think learning emacs and clojure together would be fine....especially since you have to code in lisp to configure it in the first place
22:16justin_smithradioactiveoctop: if you have a year or two free and not much else to do, sure
22:17caternjustin_smith: oh come on
22:17bsimaI learned emacs and clojure at the same time. It's worth it. Only took me a few weeks to get the hang of REPL development
22:18bsimaand that was only in my free time
22:18bsimaI used this a ton braveclojure.com/using-emacs-with-clojure/
22:18bsimafantastic little intro
22:18caternthe entirety of http://www.braveclojure.com/ is great
22:19caternyou'd probably want to start from the beginning of it, not that specific section
22:20bsimaagreed. That section was just first in my history in Chrome, so I must have used that section most :)
22:21cj3kim_thanks.
22:22cj3kim_catern: I will look into it
22:34PigDudedo you make things private in your clojure code?
22:34PigDudei see some code that never makes anything private
22:35jeremyheileri lean towards keeping thigns public, unless they truly are an implementation detail that really should not ever be called ever elsewhere.
22:37yedibeen out of the loop for a while
22:37yediwhats the coolest clojure thing you've seen in the last 1-2 months
22:37hellofunkcj3kim_ emacs is probably the most-used IDE for clojure and is very powerful.
22:38hellofunkcj3kim_ here's a cheatsheet of emacs commands useful in clojure work i put together: https://github.com/hellofunk/emacs-clojure-hints
22:38fifosine,(.indexOf "ABC" \A)
22:38clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: indexOf for class java.lang.String>
22:38fifosinewhy doesn't that work?
22:38fifosineString has an indexOf function
22:38cj3kim_hellofunk: thanks you
22:39radioactiveoctopanyone working on anything cool?
22:40jeremyheiler,(.indexOf "ABC" "A")
22:40clojurebot0
22:41jeremyheiler,(.indexOf "abc" 97)
22:41clojurebot0
22:41jeremyheiler,(.indexOf "abc" 98)
22:41clojurebot1
22:41jeremyheilerfifosine: indexOf takes either a string or an int.
22:41fifosineI have to cast the char as an int?
22:41jeremyheileror a string..
22:41TEttingeryou can, yeah, or str it
22:42fifosineblech, this is so messy
22:42TEttingerit's the java API for whatever reason
22:42jeremyheilerindexOf doesn't imply a single char
22:42arrdemare there any tools for automated formatting of Clojure forms? I know that core.pprint has one, but it's not especially good at producing human-like code or fast.
22:42jeremyheiler,(indexOf "abcdefg" "cde")
22:42clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: indexOf in this context, compiling:(NO_SOURCE_PATH:0:0)>
22:42fifosineindexOf a character? why not?
22:42jeremyheiler,(.indexOf "abcdefg" "cde")
22:42clojurebot2
22:46jeremyheilersorry, it can imply a single char, as an int. because java.
22:47justin_smith,(.indexOf "ABC" (int \A))
22:47clojurebot0
22:54sritchietechnomancy: looks like I might have a leiningen 2.4.2 bug
22:54sritchieCaused by: clojure.lang.ArityException: Wrong number of args (3) passed to: server/default-handler
22:54sritchietechnomancy: due to this: :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
23:02lispahi all, if someone says they will be sending you a 16 bit unsigned integer what does that mean?
23:02lispathis is an example 088C the person showed me
23:03arrdem&(format "%X" (dec (apply * (repeat 2 16))))
23:03lazybot⇒ "FF"
23:04arrdemwell whomever they are, they gave you an out of apparent bounds value...
23:06lispaarrdem: kk thanks, but how do i decipher that or start to break it apart, what does 16 bits mean?
23:06jeremyheilerarrdem: a hex digit represents 4 bits, so 16 bits is 4 hex digits
23:07arrdem&16rF
23:07lazybot⇒ 15
23:09TEttinger,(Integer/parseInt "088C" 16)
23:09clojurebot2188
23:10jeremyheilerlol
23:10TEttinger,(Integer/parseInt "FFFF" 16) ; this will work
23:10clojurebot65535
23:10lispathanks guys
23:10TEttingerbut
23:10lispaso what would be bit 0?
23:10TEttinger,(Short/parseShort "FFFF" 16) ; this will work
23:10clojurebot#<NumberFormatException java.lang.NumberFormatException: Value out of range. Value:"FFFF" Radix:16>
23:10TEttingerthis will not work*
23:11jeremyheilerif he wants an unsigned int, probably should stick with int
23:11TEttingerso you'll represent these as ints yes
23:11jeremyheilerints are 32 bits
23:11jeremyheilersigned
23:11TEttingereven though short is a 16-bit type, it has 1 bit uses to tell positive or negative, so...
23:11TEttinger,Short/MAX_VALUE
23:11clojurebot32767
23:11jeremyheileryes, because it's signed
23:12TEttinger(jeremyheiler, I'm just explaining the terms)
23:12jeremyheilergotcha sorry
23:13TEttingerthere are some tricks here -- if it's strings being sent from an unknown source, you should check that it's within the minimum and maximum of a 16-bit unsigned int.
23:13lispaTEttinger: do you have an article i can read about this
23:14TEttinger,(Integer/parseInt "-FFFF" 16) ; this will technically bypass the initial check
23:14clojurebot-65535
23:14lispain terms of how to convert and read them
23:14TEttingerwell how are they being given to you,lispa?
23:14arrdemis there some reason why you would implement a number reader yourself when it's been a solved problem with library code for decades?
23:15TEttingerit's a good question though, strings can be converted by any java program using the standard lib (which clojure uses too)
23:15justin_smithalso, if you are getting the data as bytes, there are methods on byte-array to cast the next n bits as a specific primative type
23:16lispaTEttinger: an instrument will post it status to an endpoint
23:16justin_smithlispa: what encoding?
23:16justin_smithlispa: ascii? json? raw bytes?
23:16lispajson string
23:16justin_smithuse cheshire
23:17TEttinger$google cheshire clojure
23:17lazybot[dakrone/cheshire · GitHub] https://github.com/dakrone/cheshire
23:17justin_smithhttps://github.com/dakrone/cheshire
23:17justin_smithheh, beat me to it
23:17lispabut i would like to do it in my mind and understand whats going on first
23:17lispaso in the table it says bit 0 means this
23:17lispaif the value is 1 or 0
23:18TEttingerlispa, are you just learning how binary works?
23:19TEttingerthere may be some better resources
23:19lispaTEttinger: i have an ok understanding
23:21TEttingerwell bit 0, which we'll say is the least significant bit, is the same as the "1s place" in normal counting, it just can only go from 0 to 1 instead of 0 to 9. then instead of a 10s place you have a 2s place in binary, after that a 4s place, so now we can do some counting
23:21TEttinger001 -> equal to 1
23:22TEttinger010 -> equal to 2, 011 -> equal to 3
23:22sritchietechnomancy: deleting .repl fixed it
23:22arrdemis there a "standard" file extension for REPL input/output sessions?
23:23TEttingersee how it goes? a 1 in the 1s place is +1, a 1 in the 2s place is +2. starting at 0, 011 is 0 (4s place) + 2 (2s place) + 1 (1s place)
23:23kristofarrdem: .log?
23:23arrdemthat'll do.
23:24lispaTEttinger: ahh i get that but then where does the 16 bits come in
23:24kristofarrdem: Be sure to put the date on the file's name, too. I doubt you're saving a REPL output once and never doing the same thing for the same application ever again.
23:25arrdemkristof: oh these aren't real logs... these are examples that are named by the hash of the contents as a Java string.
23:25arrdemorder and dates being things IDGAF about
23:25kristofStrike my suggestion, then
23:26arrdem:P
23:26TEttingerlispa, a 16 bit number has 16 places -- I could list them but it's easier just to do ##(map #(bit-shift-left 1 %) (range 0 16))
23:26lazybot⇒ (1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768)
23:26arrdemkristof: reworking Grimoire's examples system ATM, just needed a name for when I stashed single examples in files.
23:26TEttingerso normally it is written reversed, but it's different internaly sometimes
23:27lispaTEttinger: so 8204 would get expanded?
23:27lispaor would i ahve to convert that to a 16bit number
23:27TEttingerare you getting it as a string?
23:28TEttingerif you're parsing json, you should use a json lib, but I guess json is all strings anyway (just some are strings inside the json text)
23:29lispayep getting it as a string
23:29TEttingerso it's most likely you're getting them as numbers in the json, like 8204 instead of "8204"
23:29lispayea you are right
23:29TEttingerbut that 8204 is in a longer string, which starts with { and ends with }
23:29lispaso then i need to figure out what 8204 is in a 16bit form?
23:29TEttingerno, I was a bit confused, it already is
23:30TEttinger16-bit is how big it can get, unsigned is whether it can be negative or not
23:30TEttingerso you can see this in a simple way in clojure like this:
23:30kristofIf it's signed, it can only be as big as 15 bits.
23:30TEttinger,2r1111111111111111
23:31clojurebot65535
23:31kristofEr, that came out wrong, but hopefully someone will understand what I mean.
23:31TEttingerthat's 16 bits in binary
23:31TEttingerand when someone gives you any number, you check if it;s less than or equal to 65535 and greater than or equal to 0
23:31kristoflispa: Take a systems programming course and learn C
23:32TEttingerif it isn't, it won't fit in a 16-bit unsigned number
23:33TEttingerif you know they're 16-bit unsigned numbers already, you can just ##(Integer/parseInt "8204")
23:33lazybot⇒ 8204
23:34TEttingerbut really you should use cheshire for reading json, it solved all this already and will probably be faster and more reliable than a new codebase
23:36lispathanks for all the knowledge
23:50TEttingerno prob