Re: How to tell buffy which file to read?

2015-10-23 Thread Amith George
Hi Alex, > first one is to slice the buffer and then feed it to buffy, which means that you have to implement streaming yourself. Is this the same as say manually skipping till byte position X, read in 1MB (as described by the size bytes) of data into a buffer and pass that buffer (and a corre

Re: How to tell buffy which file to read?

2015-10-21 Thread Amith George
. I was hoping to somehow avoid that using buffy and its spec. On Wednesday, 21 October 2015 20:09:58 UTC+5:30, Amith George wrote: > > I am interested in using buffy[1] to read data from multiple binary files. > The files have sizes varying from 10MB to 500MB. From the documenation,

How to tell buffy which file to read?

2015-10-21 Thread Amith George
I am interested in using buffy[1] to read data from multiple binary files. The files have sizes varying from 10MB to 500MB. From the documenation, buffy seems to work directly on a buffer and not a file. It can either create a heap or off-heap buffer of size equaling the size of the spec or it

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread Amith George
>> I probably wouldn't use protocols since I doubt there is a function signature that is exactly identical for all branches. Each branch probably needs access to different parts of your system (eg. database) and always passing everything to everything is not ideal. >> Multi-Method is great if y

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread Amith George
> > Looking at the "(defn register [...])" example. Where is the problem with > the first solution? It doesn't have the bugs the other implementations have > and is extremely simple to reason about? The other two solutions do the > exact same thing just slower with absolutely no gain. If you ne

Re: Just found out about Elixirs function argument pattern matching...

2015-09-06 Thread Amith George
In a possible messaging system, a user could denote a recipient using one of three ways - 1) select an existing user id, 2) enter a new name and email, 3) pick a placeholder "all my team mates". Possible F# (might not compipe!!) Recipient = | Placeholder of string | Existi

Re: Just found out about Elixirs function argument pattern matching...

2015-09-06 Thread Amith George
TIL that "tagged literals" have an existing meaning in clojure. In my mind, the terms "tagged vector" and "tagged literal" were interchangeable. From a quick Google search there doesn't seem to be an existing meaning for "tagged vector". I think we can agree that it a representation of variants

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
defun, core.match, tagged vectors - seems like I can emulate Elixir function pattern match behaviour. I took some simple code I found online (https://twitter.com/Xzilend/status/640282621042233344) and rewrote it to 1) use only tagged vectors (not quite) and 2) use defun and tagged vectors. I am

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
In Elixir, tuples are used where in the first element is the tag. A similar thing can be done in Clojure using vectors. That much was clear. What bothered me and prompted me to start this thread was I wasn't sure "what" it is I was doing by creating that vector. Was it purely a convention thing

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
. %) > low-severe 1 (1.6667 %) > low-mild 8 (13. %) > Variance from outliers : 17.3434 % Variance is moderately inflated by > outliers > > --- > > > On 5 Sep 2015, at 05:16, Amith George > > wrote: > > Nice. Hadn't h

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
Thanks, it helps to know using a tagged vector is a real pattern :) Gives the confidence to explore this further for my own code. On Saturday, 5 September 2015 22:37:33 UTC+5:30, Gary Verhaegen wrote: > > It won't really help for the library/ecosystem problem, but for your own > code I'd recomm

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
Nice. Hadn't heard of it before. It looks interesting. The criterium benchmark is kinda disappointing though. The pattern matched function took nearly 15x the time of the normal function. Performance aside, in Elixir, there seems to be an established convention for creating the function argumen

Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread Amith George
Hi, I just read a blog post [1] talking about Elixir pattern matching. I was thoroughly impressed with the way its handled in Elixir. I am posting this here cuz I got rather excited and wanted to discuss this with you all. My experience with pattern matching is limited to the basics of F# and

Re: feedback about solutions

2015-09-01 Thread Amith George
Forgot to add, there is a community written clojure style guide [1] that you may skim through. I had read it a long time ago. My impression was that a lot of the guidelines aligned with my own preferences. [1] - https://github.com/bbatsov/clojure-style-guide -- You received this message becau

Re: feedback about solutions

2015-09-01 Thread Amith George
Hi, I am not an expert :) I haven't heard of this repo or even understand what the exercises are. Nonetheless, based on what you wrote, some simple changes (to possibly make it more idiomatic?), (< x 0) use (neg? x) (if (= (mod n divisor)0) > true > false)) use (= (mod n d

Re: Function syntax

2015-08-13 Thread Amith George
Maybe you meant to use `vector` instead of `vec`? `vec` doesn't accept variable args. Hence my original question. On Thursday, 13 August 2015 16:24:43 UTC+5:30, Herwig Hochleitner wrote: > > 2015-08-13 11:13 GMT+02:00 Amith George > > : > >> >> Could you please

Re: Function syntax

2015-08-13 Thread Amith George
would work, not `vec`. It should be `((comp last sort list) 3 2 1)`. Please correct me if I am understanding this wrong. On Thursday, 13 August 2015 16:13:24 UTC+5:30, Tassilo Horn wrote: > > Amith George > writes: > > >> That's not the same function as #(last (sor

Re: Function syntax

2015-08-13 Thread Amith George
Hi, That's not the same function as #(last (sort %&)) > The equivalent would be (comp last sort vec) Could you please explain why is the `vec` needed? From what I understand, we are expected to treat the variadic args argument as a seq, nothing more. On Thursday, 13 August 2015 14:02:38 UT

Re: My first Clojure program (and blog post about it)

2015-07-30 Thread Amith George
Hi, >From a cursory glance, I didn't really understand the domain, so the function names I used in my rewrite might seem silly. But I wanted to illustrate that there is a lot of repetition in your code. Also discrete functions (with proper names) can make the code easier to grok. https://gis

Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-20 Thread Amith George
gt; > passed-in function and type-hinted ^Paper argument > > - visible-color-frequencies - switched to nested loop-recur, moved out > > height and width to single call outside critical loop > > > > Could you try the version from the gist there to see if you

Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-20 Thread Amith George
Wow. This is rather hard to believe. But the execution time is now 10s. :D All of your suggestions were on the mark. I implemented them in stages/commits. The command to execute the file remains the same - `lein run -m rdp.214-intermediate-arr 1 true` 1. Replaced the coordinates vector with sep

Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-19 Thread Amith George
Hi, Thank you for taking the time. That is a rather smart algo. The code and the changes were easy to understand. I didn't implement the parallelized version as my aim was to understand why the clojure version was so slow compared to the equivalent C# version. (Btw, you have access to a 12 co

Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-19 Thread Amith George
Hi, Thanks for taking the time to profile the code. I implemented the two suggestions (using the two argument arity of lte and using aset inste

Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-15 Thread Amith George
u're processing larger datasets, I think it's reassuring that once > warmed up, the Clojure code performs pretty well. > > For reference, this was run on an Macbook Pro 13" early 2011, Core i7 > 2.7ghz. > > steven > > [1] - https://github.com/hugoduncan/

Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-15 Thread Amith George
Thanks for the detailed suggestions. Implementing them did bring the execution time down to around 250secs. Though that value is still much longer than 45secs. Could you please verify if I have implemented them correctly? Code - https://github.com/amithgeorge/reddit-dailyprogrammer-clojure/blo

Re: Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-14 Thread Amith George
I forgot to link the input files https://raw.githubusercontent.com/fsufitch/dailyprogrammer/0e4bb5ba1e3bc6e749b9e9bb49387513d5a623b7/ideas/pile_of_paper/100rects100x100.in https://raw.githubusercontent.com/fsufitch/dailyprogrammer/0e4bb5ba1e3bc6e749b9e9bb49387513d5a623b7/ideas/pile_of_paper/100re

Why does the following Clojure code take 10x the time the C# version does? How to improve the Clojure version?

2015-05-14 Thread Amith George
I wrote the following code to solve this challenge - https://www.reddit.com/r/dailyprogrammer/comments/35s2ds/20150513_challenge_214_intermediate_pile_of_paper/. Code - https://github.com/amithgeorge/reddit-dailyprogrammer-clojure/blob/56ce1dbb6a08e96150dc85934caecfeb68108a53/src/rdp/214_interme