This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-05
Channels
- # aleph (2)
- # beginners (93)
- # boot (9)
- # cider (1)
- # cljs-dev (50)
- # cljsrn (4)
- # clojure (32)
- # clojure-russia (58)
- # clojure-spec (23)
- # clojurescript (146)
- # clojurewerkz (2)
- # component (1)
- # cursive (2)
- # hoplon (163)
- # off-topic (4)
- # om (117)
- # onyx (8)
- # pedestal (1)
- # re-frame (13)
- # reagent (34)
- # spacemacs (17)
- # test-check (1)
- # untangled (3)
My guess is that I can do
(dynamic-buffer
(composite-frame
:a (int32-type)
:bf bit-field-frame)))
Very newbie question: why acc is always {}
on every iteration of map?
(let [acc {}]
(map
(fn [item]
(has-kids? acc item msgs))
msgs))
i expected it to be like a first arg in reduce
@olegakbarov Because you never actually change the acc value. Its defined, and then referred to in has-kids?
. Data in clojure is immutable so whenever you try to change acc you create a new value in that scope based on acc. Reduce and other functions like it is based on recursion so that you take a value, do whatever to it and the run the same function with a 'new' variable that came from the previous recursion building it up for each pass. I'm unsure exactly what you're trying to do since I don't know what has-kids?
do but maybe you could wrap your map in into {}
so that whatever result you get back from map
is put in a map? Something like this:
(into {}
(map
(fn [item] item)
[[:foo "bar"] [:baz "qux"]]))
I hope that explanation was accurate 🙂 my best go at it anyways.@roosta thanks!
i felt like let binding creates ‘shared’ scope for all functions
it does, but still every attempt to change it creates a new value. If you wanted a value that you could change you'd have to use an atom. It's tricky to wrap your head around immutable data if you're used to other languages.
Trying to massage this:
[[“id” “name”][1 “one"][2 “two"][3 “three"]]
into that: [{:id 1 :name “one”}{:id 2 :name “two”}{:id 3 :name “three"}]
Help!
It looks like a case for mapv. Will try.
(let [keys (map keyword (first data))]
will get me the keys. Then somehow need to “pivot” that with (rest data).(fn [[header & rows]]
(let [header-keys (map keyword header)]
(map #(zipmap header-keys %) rows)))
zipmap...
reading up on it
brilliant. I hadn’t spotted that one. Thanks a lot. Exactly what I needed.
A lot of useful fns to remember in clojure. That’s the beauty of it. It’s probably already in place, whatever the need.
Exactly what I was doing.
Using CSV parse with cljs-ajax to fetch remote csv data
Trying to reagent-friendlify the mapbox leaflet map lib
using 43000 rows of data
the nasty part being the “reagenting” of stateful leaflet maps. head hurts.
Thanks @dominicm this clears a hurdle
buffy?
octet?
So I’m trying to parse a file with data like this: int32 int32|string. I don’t know how to combine a Primitive type with a frame-type
@markx i’m using clojure happily with essentially zero java knowledge 🙂
@markx haven’t done much heavy lifting with files though, mostly been working in the browser
@thedavidmeister That’s very good to know. Guess I happened to start on the tough task.
@gamecubate Could you help me a bit here?
I’ve never used it and am looking it up now. Hang on.
frame-type? Only ever heard of that in R programming.
And what does "combine" mean in this context? (add? concatenate? put in a list? assoc? or something else?) @markx
so my question is, wow do I construct a buffer that includes both buffy’s primitive types and dynamic frames?
Not really, looks to be part of some library, I could make guesses but so far they've been wrong (thought it might have something to do with decoding/encoding network frames). Maybe a more expert Clojure programmer will understand without context or guess the library markx
It doesn't even look like built-in Clojure to me -- could be wrong easily -- so what are function/spc-form/macros dynamic-buffer frame-type frame-encoder frame-decoder?
Working backwards my guess is frame-type might be a macro which is making functions out of the encoder/decoder
Anything in first position of a form has to act like a funtion ( e.g., a macro or special form or somehow be interpreted as data by some other part of the program, i.e some macro or spc. form.
See the only doc for this lib I could find is the project’s README file, and it doesn’t seem to cover my use case, so I got lost.
Ok, so maybe I came in too late to help (reading back) -- "this library"? What are you really trying to accomplish? What is the current issue? (unless you already received help)
So the question is, I’m trying to parse a local binary file. Someone pointed me to https://github.com/clojurewerkz/buffy. The binary file is this: https://aria2.github.io/manual/en/html/technical-notes.html
"wow do I construct a buffer that includes both buffy’s primitive types and dynamic frames?" What would that mean and what would it do? Are you trying to assemble/compose a datatype supporting multiple interfaces?
(I am personally not very knowledgeable about Clojure interfaces and object like structures -- just haven't spent much time with those yet.)
Nothing like that. This is more of a question about the library, and less about Clojure.
This is probably more than a 'beginners' question so you might also post in one of the other threads but first clarify what exactly you are asking and assemble the details
You'll need to be pretty specific, about your GOAL at least. There are many ways to "combine" -- from a simple as a list (probably not what you want) to perhaps hash table with a key and value for each piece {:buffy-buffer buffer :dyn-frame dframe} to some type of record or even reified object with interfaces
Well only people who are beginners or who like to help beginners are likely to read this channel (or who read everything :) @markx
I am a near beginner who knows a few things so like to read and try to help here 😉 @markx
Let’s say this, My question is, how to parse that file I posted, using the library buffy.
I didn't really say anything specific or useful, just threw out some possibilities for what you might be asking which is still pretty vague
Are the docs not useful for that? Who wrote the buffy library? Is it someone who's an identifiable member here?
(Sounds like the guy, Daniel Higginbotham, who wrote one of the better newbie Clojure books, "Clojure for the Brave and True". He loves TV & vampire allusions etc.
@markx found this http://stackoverflow.com/questions/12310017/how-to-convert-a-byte-to-its-binary-string-representation
@markx you can simply translate one of the examples from Java to Clojure, using loop
and the bitwise operators in clojure.core. But honestly, for this kind of low-level stuff, I prefer sticking to Java.
@markx you only need to know how to copy and paste java for this purpose 🙂
Here's a more Clojury implementation, but don't expect it to be fast!
@markx I don't think it's that common a use case in practice
you usually don't care what the individual bits are when passing bytes around
it's telling that there's nothing built-in for Java either
Yeah that’s true. Using Java we can do this (Integer/toBinaryString (Byte/toUnsignedInt -1))
@val_waeselynck Will you happen to know clojurewerkz/buffy ?