Re: Seeking a function to partially parallelize collection processing

2017-06-17 Thread Sam Raker
core.async pub/sub ? On Friday, June 16, 2017 at 10:13:11 AM UTC-4, Tom Connors wrote: > > I'm looking for a function that would likely be named something like > "sequential-by" or "parallel-per" that takes some data-producing thing like > a la

Re: Filtering lazy sequence on itself - Eratosthenes Sieve

2015-11-05 Thread Sam Raker
Clojure doesn't do TCO with recursive functions--you have to use `loop`/`recur`[1]. This is one of the (thankfully few) "gotchas" in Clojure, at least/especially for people coming from other functional languages (or so I assume--coming from Python, I hadn't heard that much about TCO in the firs

Re: Decomplecting Clojure

2015-08-13 Thread Sam Raker
Default laziness can cause problems, but I'm not sure that they're bad problems, necessarily. I think 'opt-out' laziness (and the headaches it can cause) push people--especially people coming from non-FP backgrounds--to really zero in on writing pure, focused functions. On the other hand, from

Re: Hashing With Consistent Results

2015-08-13 Thread Sam Raker
Could you use something like Redis? Use hashes as keys, fake immutability by 'popping' kv pairs and inserting new ones keyed to the (presumably different) hash of the updated map. On Thursday, August 13, 2015 at 7:52:06 AM UTC-4, Christian Weilbach wrote: > > -BEGIN PGP SIGNED MESSAGE-

side-effecting re-/transducers

2015-06-25 Thread Sam Raker
This seems bad, is this bad: (defn to-db [conn] (fn ([val] (upload-to-my-db conn val)) ([_ val] (upload-to-my-db conn val))) (defn -main [] (transduce my-preprocessing-xf (to-db (get-db-conn)) seq-of-things-to- preprocess-and-upload)) I ask only because 1) Plugging the side-effec

Re: transducer (+ closures) efficiency question

2015-06-23 Thread Sam Raker
> once and the value inside the var will be passed to `remove` at the > outset. In the second example the var dereference happens for every single > item (though it's very cheap). The second example is equivalent to writing > (remove > #'even?) > > On Tuesday, June 23

transducer (+ closures) efficiency question

2015-06-23 Thread Sam Raker
Let's say that, as part of an xf, I want to filter out everything in a sequence that's also in some other sequence. Here are some ways of doing that: (defn filter-contains1 [edn-file] (remove (partial contains? (set (read-edn-file edn-file) (defn filter-contains2 [coll] (remove (partial c

Re: neocons get record from cypher query

2015-05-17 Thread Sam Raker
Figured it out: `neocons.rest.records/instantiate-record-from` does the trick. On Sunday, May 17, 2015 at 7:09:35 PM UTC-4, Sam Raker wrote: > > I'm using neocons to put some data into a Neo4j database. I need to create > relationships between nodes I've just created and

neocons get record from cypher query

2015-05-17 Thread Sam Raker
I'm using neocons to put some data into a Neo4j database. I need to create relationships between nodes I've just created and nodes in the DB. I can't retrieve the nodes based on id without caching them locally, and they're not unique enough to retrieve using e.g. rest.nodes/find, so I need to us

Protocols/multimethods vs core.match

2015-05-15 Thread Sam Raker
The discussion/post-linked-to in https://groups.google.com/d/msg/clojure/eoAp6QVimYI/iipmEJNKdrIJ have got me thinking about protocols & multimethods, which I admittedly have possibly never actually used, now that I think about it. I'm wondering how they differ from core.match[1]. I realize pro

Re: contains? on String

2015-05-13 Thread Sam Raker
I always assumed (contains? "foo" 2) worked because strings are arrays (i.e. vectors) of characters, on some level. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from n

Streaming a big file

2015-05-05 Thread Sam Raker
I've got two really big CSV files that I need to compare. Stay tuned for the semi-inevitable "how do I optimize over this M x N space?" question, but for now I'm still trying to get the data into a reasonable format--I'm planning on converting each line into a map, with keys coming from either

code-rewriting "with-connection" macro (monger and maybe beyond?)

2015-04-12 Thread Sam Raker
I'm working with Monger[1], and have been thinking about connection encapsulation. I've currently got a `myproject.mongo` ns with private `db` and `coll` vars. I've got a public `insert` method along the lines of (defn insert [m] (mc/insert db coll m)) where `mc/insert` is, perhaps unsurprisin

Re: [OT?] Best DB/architecture for n-gram corpus?

2015-03-12 Thread Sam Raker
On 10 March 2015 at 20:03, Sam Raker > > wrote: > > That's honestly closer to what I was originally envisioning--I've never > > really looked into graph dbs before, but I'll check out Neo4j tonight. > Do > > you know whether you can model multiple

Re: [OT?] Best DB/architecture for n-gram corpus?

2015-03-12 Thread Sam Raker
eature, so you could search for e.g. "the ADJ goose", but that's a whole other layer of stuff, so it might go in the "eventually, maybe" pile. On Tuesday, March 10, 2015 at 3:47:37 PM UTC-4, Ray Miller wrote: > > On 10 March 2015 at 17:58, Sam Raker > > wrote:

Re: [OT?] Best DB/architecture for n-gram corpus?

2015-03-10 Thread Sam Raker
at a low priority :) > > (And I think the Google n-gram corpus > <https://catalog.ldc.upenn.edu/LDC2006T13> uses the same format.) > > > John > > > On Mon, Mar 9, 2015 at 7:09 PM, Sam Raker > > wrote: > >> That's interesting. I've bee

Re: [OT?] Best DB/architecture for n-gram corpus?

2015-03-09 Thread Sam Raker
That's interesting. I've been really reluctant to "hard code" n-grams, but it's probably the best way to go. On Monday, March 9, 2015 at 6:12:43 PM UTC-4, John Wiseman wrote: > > One thing you can do is index 1, 2, 3...n-grams and use a simple & fast > key-value store (like leveldb etc.) e.g.,

Better/more idiomatic way to read EDNs than using java.io.PushbackReader

2015-03-06 Thread Sam Raker
I'm experimenting a little with EDN files. I've currently got this function: (defn from-edn [edn-file] (with-open [r (clojure.java.io/reader edn-file)] (edn/read (java.io.PushbackReader. r Having to explicitly reach into the Java API to read a clojure-only format

[OT?] Best DB/architecture for n-gram corpus?

2015-03-06 Thread Sam Raker
I'm trying to create an n-gram[1] corpus out of song lyrics. I'm breaking individual songs into lines, which are then split into words, so you end up with something like {0 {0 "go" 1 "tell" 2 "aunt" 3 "rhodie"} 1 {0 "the" 1 "old" 2 "grey" 3 "goose" 4 "is" 5 "dead"}...} (Yes, maps with integer

Re: Disk based caching for Clojure app

2015-03-06 Thread Sam Raker
I'm under the impression that, because of the hard limit on writes, OSes often already cache writes to SSDs, further limiting their usefulness in this kind of application. On Friday, March 6, 2015 at 4:10:54 PM UTC-5, Fluid Dynamics wrote: > > On Friday, March 6, 2015 at 3:16:09 PM UTC-5, Michae

Re: :reload does not always work correctly in leiningen

2015-02-28 Thread Sam Raker
"does not always work correctly " in what context? In the REPL, `(require '[my.ns :as mine] :reload-all)` should work. `defonce` and `defmulti` might also be causing confusion. You could also look into `clojure.tools.namespace.repl` (https://github.com/clojure/tools.namespace#reloading-code-usa

Re: printf does not always generate output

2015-02-27 Thread Sam Raker
I have https://jafingerhut.github.io/cheatsheet/grimoire/cheatsheet-tiptip-cdocs-summary.html bookmarked and also like basically always open in a tab forever, fwiw. On Friday, February 27, 2015 at 4:37:38 PM UTC-5, Cecil Westerhof wrote: > > 2015-02-27 20:36 GMT+01:00 Andy Fingerhut >: > >>

Re: How to create jar for data.int-map

2015-02-19 Thread Sam Raker
ar the top. If they don't, clojars or maven should have it. On Thu, Feb 19, 2015 at 11:19 AM, Cecil Westerhof wrote: > > > 2015-02-19 17:00 GMT+01:00 Sam Raker : > >> @Cecil: while it's a little irritating that there's not more >> centralization of third-

Re: How to create jar for data.int-map

2015-02-19 Thread Sam Raker
@Cecil: while it's a little irritating that there's not more centralization of third-party Clojure libs, I've found that Leiningen + some googling solves the problem like 99% of the time. On Thursday, February 19, 2015 at 10:42:43 AM UTC-5, Alex Miller wrote: > > The first line of the readme for

Re: getting enlive not to parse something

2015-02-14 Thread Sam Raker
wrote: > > Enlive by default uses tagsoup to parse html and can also use jsoup, so > I'd start with parsing options for those. It can also be used with other > parsers, provided you can get them to generate clojure's xml map format. > > 2015-02-13 18:55 GMT+01:00 Sam R

getting enlive not to parse something

2015-02-13 Thread Sam Raker
I'm trying to parse some stuff with enlive, but part of at least of the pages look like: ... ... <8-bar break...> ... Enlive interprets the text in the pointy braces as html, which it isn't, and that's messing up my application. Is there a way to tell enlive to not parse anything within a giv

Re: 1.7.0-alpha5 clobber warning error?

2015-02-12 Thread Sam Raker
ey. > > In the user namespace where you are making your doc calls, the name update > still refers to clojure.core/update. > > Andy > > On Wed, Feb 11, 2015 at 5:53 PM, Sam Raker > wrote: > >> I just added monger as a dependency to my Clojure 1.7.0-alpha5 project, &

1.7.0-alpha5 clobber warning error?

2015-02-11 Thread Sam Raker
I just added monger as a dependency to my Clojure 1.7.0-alpha5 project, and saw the following in my repl: user=> (require '(monger [core :as mg] [collection :as mc])) WARNING: update already refers to: #'clojure.core/update in namespace: monger.collection, being replaced by: #'monger.collection/

Re: Extending the LispReader with "embeded language lorms"

2015-02-10 Thread Sam Raker
For a competent English speaker/reader, Infinite Jest is "hard to read" because it's dense and elliptical &c. &c. For that same reader, Tintin in the original French is "hard to read" because it's in French. I think that's a relevant distinction to make in this context. Extensibility is nice, b

parameterized/-izable transducers

2015-02-09 Thread Sam Raker
So I've written a transducer to build up urls from relative links: (defn build-url ([root] (fn [xf] (fn ([] (xf)) ([links] (xf links)) ([links suffix] (xf links (let [root (if (.endsWith root ".html")

Re: remote nrepl/gorilla + port forwarding

2015-01-15 Thread Sam Raker
rnally accessible. > - then you should be able to securely access Gorilla on the remote machine > at `http://localhost:8090/...` <http://localhost:8090/...>. SSH will > route this as described above. > > A diagram would really help here with all of the ports, but hopefully you

remote nrepl/gorilla + port forwarding

2015-01-14 Thread Sam Raker
I've got a computer with a bunch of clojure code on it, sitting at home on my home network. I've configured my router to forward port 5 on that computer to port 5 on the router itself, so that, at least in theory, ROUTER_IP:5 should be forwarded to THAT_COMPUTER:5, if that makes

Re: Q: How to parse stream of text (from java.io.Reader) via instaparse with minimal input consuption

2015-01-14 Thread Sam Raker
How structured/delimited is the "other" part? Could you write your parser in such a way as to parse what you want and then return the rest as a single chunk you could then pass to something else? On Tuesday, January 6, 2015 at 11:50:26 AM UTC-5, henrik42 wrote: > > Hi all, > > I want to parse a

Re: DSL in RTL (Right to Left) languages.

2015-01-14 Thread Sam Raker
I think there's something to be said for non-English programming languages, primarily for the reasons the OP suggested--toy/beginner languages to get more people coding. Languages are judged for "readability" and similar metrics, with (standard) English as the yardstick. "Code in English because

Re: Help with Incanter and Emacs

2015-01-13 Thread Sam Raker
For something that's been "deprecated" for a while now, `use` sure still shows up in A LOT of docs/tutorials/books/etc. On Monday, January 12, 2015 at 7:48:44 PM UTC-5, Robert Berger wrote: > > Wish this was in the Incanter docs and in the Readme > > On Tuesday, August 13, 2013 at 12:09:20 PM UTC

Re: [ANN] Neanderthal, a fast, native matrix and linear algebra library for Clojure released + call for help

2015-01-13 Thread Sam Raker
I'd like to politely add to the calls for this to become a pluggable core.matrix backend. On Tuesday, January 13, 2015 at 4:38:22 PM UTC-5, Dragan Djuric wrote: > > It would be nice if that would be that easy. However, I am sceptical... > > On Tuesday, January 13, 2015 at 8:13:36 PM UTC+1, Christ

Re: Handling increasingly-intensive processes

2014-12-16 Thread Sam Raker
way. > > "Bit Data" and "Distributed Systems" are hard and cannot be described in > short. Without exact knowledge of what your app/business needs look like it > is impossible to make the "correct" recommendation. > > HTH, > /thomas > > On

Handling increasingly-intensive processes

2014-12-14 Thread Sam Raker
I'm (still) pulling tweets from twitter, processing them, and storing them in CouchDB with hashtags as doc ids, such that if a tweet contains 3 hashtags, that tweet will be indexed under each of those 3 hashtags. My application hits CouchDB for the relevant document and uses Cheshire to convert

Re: futures + refs

2014-12-11 Thread Sam Raker
eams feed the same > queue and have a single thread do the upload (and maybe batch if necessary). > > I don't see refs being a particularly good fit for this problem, but I > could be wrong. > > > 2014-12-11 16:18 GMT+00:00 Sam Raker : > >> I've got some code t

futures + refs

2014-12-11 Thread Sam Raker
I've got some code that's using Twitter's HoseBirdClient to pull tweets from the public stream, which I then preprocess and store with CouchDB. Right now, my HBC client is being forced to reconnect more than I'd like, which occasionally causes my app to hang, for reasons I'm not entirely clear

Re: more colloquial "do x n times"

2014-12-03 Thread Sam Raker
EDIT On Wednesday, December 3, 2014 10:45:33 PM UTC-5, Sam Raker wrote: > > I've got a decent-sized corpus of tweets, organized by hashtag, in a > CouchDB db. I'm doing some initial explorations of my data, and was curious > about which hashtags show up together in twee

more colloquial "do x n times"

2014-12-03 Thread Sam Raker
I've got a decent-sized corpus of tweets, organized by hashtag, in a CouchDB db. I'm doing some initial explorations of my data, and was curious about which hashtags show up together in tweets. I want to do a NSA-style "hops" kind of algorithm--get all the hashtags that show up in the same twee

Clutch timeout problem

2014-11-18 Thread Sam Raker
I asked this in the Clutch group, before I realized the last time anyone else had posted there was last year... I have some code that connects to a CouchDB server using Clutch (https://github.com/clojure-clutch/clutch). I recently changed the connection to use a non-local connection, i.e. (de

Re: loop problems

2014-11-12 Thread Sam Raker
e no evidence that the thread is > doing anything. (I.e. your first function will hang forever and appear to > do nothing.) > > > On Wednesday, November 12, 2014 10:43:57 AM UTC-6, Sam Raker wrote: >> >> I'm using Twitter's HBC library to read from Twitter

loop problems

2014-11-12 Thread Sam Raker
I'm using Twitter's HBC library to read from Twitter's public stream. HBC stores results in a LinkedBlockingQueue, from which you can then `.take` tweets and do stuff to them (in my case, doing some processing/normalization, then storing them in CouchDB). I've been struggling with how exactly b

io/writer + map/recur

2014-10-31 Thread Sam Raker
I'm writing some stuff to interact with the Twitter API. I want to be able to write tweets (as JSON) to a file, so I can, e.g., test things without connecting to the API. I've proxied the LinkedBlockingQueue that Twitter's HBC library uses to use an agent, so ideally I want to be able to write t

Re: CCW bug [SEVERE]

2014-10-28 Thread Sam Raker
I version everything. I don't version something because it's huge, or important, or shared, or even worth sharing. I version because Git is an important and widely-used tool, and because it's better than regular saving. You've already downloaded and learned at least one programming language, yo

reorganizing/naming args with partial

2014-10-24 Thread Sam Raker
(Accidentally hit 'enter' prematurely :( ) >From what I can tell, `partial` goes 'in order'. As such, you can't pass it a fn that takes > 1 args and the 2nd...nth args. In Python, at least, you can explicitly name positional arguments, e.g. def my_func(x, y, z): return x + y * z

reorganizing/naming args with partial

2014-10-24 Thread Sam Raker
>From what I can tell, `partial` goes 'in order'. As such, you can't pass it a fn that takes > 1 args and the 2nd...nth args. In Python, at least, you can explicitly name positional arguments, e.g. def my_func(x, y, z): return x + y * z p -- You received this message because

Re: filter but for non-sequences

2014-10-24 Thread Sam Raker
(pred x) x)` looks like it’s missing an else-clause; so I don’t know what >> happens when (not (pred x)). >> >> From the rest of your e-mail it sounds a little bit like you might want >> (get m x x)? (i.e. get me x if x isn’t in m; otherwise give me the value >> mapp

filter but for non-sequences

2014-10-23 Thread Sam Raker
Is there anything simpler/more idiomatic than `(if (pred x) x)`? What I really want is something better than `(if (= (get a-map a-key) a-val) a-map)`/`(if (= (get-in a-map some-keys) a-val) a-map)`, but that might be too specific to have been 'cached' somewhere. -- You received this message be

Re: [ANN] Clojure instaREPL for web

2014-10-08 Thread Sam Raker
This is great. A little buggy, but that's to be expected :) I really appreciate the ability to hop onilne and test the behavior of little bits of code without waiting for a local repl to start up! On Tuesday, October 7, 2014 3:00:08 PM UTC-4, Lauri Hartikka wrote: > > A web based clojure instaREP

Re: Interop nightmare

2014-09-08 Thread Sam Raker
Thanks for all the help! I knew I could count on you guys. I saw that there were a bunch of params in the constructor, but naively hoped there'd be some kind of default values for them so I didn't have to muck around with anything too much. Disappointed once again. I'll look into exactly what e

Interop nightmare

2014-09-07 Thread Sam Raker
I'm trying to use the Stanford Parser from Clojure, but I don't know hardly any Java, and this is my first time working with the interop stuff. All I want to do is play around with the class in the REPL. I added `[edu.stanford.nlp/stanford-parser "3.4.1"]` to my Lein `project.clj`, and the down

Re: Puzzling list comp error: "Don't know how to create ISeq from: clojure.lang.Keyword"

2014-08-30 Thread Sam Raker
`->` inserts its first argument into the second position of the next argument, and so on, so (-> [] (conj 1) (conj 2)) Turns into (conj (conj [] 1) 2) `->>` inserts its first argument into the LAST position of the next argument, and so on, so (->> 1 (conj [2]) (conj [3])) Turns into (co

Resources for intermediate/not-absolute-beginner Clojurians

2014-08-29 Thread Sam Raker
I worked my way through *Clojure Programming* (Emerick, Carper, & Grand, O'Reilly), and I've started writing my own Clojure (porting over an unfinished Python project that seemed amenable to the Clojure treatment.) I really love the language, but I'm not sure where to go from here. My other ma

Re: positional + keyword args

2014-07-20 Thread Sam Raker
day, July 20, 2014 8:16:55 PM UTC-4, Alex Baranosky wrote: > > You can get keyword args like this: > > (defn f [& {:keys [a b c d] > :or {a 1 b 2 c 3 d 4}}] > [a b c d]) > > But you cannot also get the ability to call: > (f 5 6 7 8) > > > On

Re: positional + keyword args

2014-07-20 Thread Sam Raker
Nope, that doesn't actually work... On Sunday, July 20, 2014 8:57:47 PM UTC-4, Sam Raker wrote: > > Wait. Should be: > > (defn f [& args] (let [default-args-atom (atom {:a 1 :b 2 :c 3 :d 4}) kwds > [:a :b :c :d] > kwargs (map-indexed (f

Re: positional + keyword args

2014-07-20 Thread Sam Raker
02 PM UTC-4, Sam Raker wrote: > > I hacked this together: > > (defn f [& args] (let [default-args-atom (atom {:a 1 :b 2 :c 3 :d 4}) kwds > (vec (keys @default-args-atom)) > kwargs (map-indexed (fn [idx arg] (if > (keyword? arg) (swap! default-

Re: positional + keyword args

2014-07-20 Thread Sam Raker
02 PM UTC-4, Sam Raker wrote: > > I hacked this together: > > (defn f [& args] (let [default-args-atom (atom {:a 1 :b 2 :c 3 :d 4}) kwds > (vec (keys @default-args-atom)) > kwargs (map-indexed (fn [idx arg] (if > (keyword? arg) (swap! default-

Re: positional + keyword args

2014-07-20 Thread Sam Raker
rote: > > You can get keyword args like this: > > (defn f [& {:keys [a b c d] > :or {a 1 b 2 c 3 d 4}}] > [a b c d]) > > But you cannot also get the ability to call: > (f 5 6 7 8) > > > On Sun, Jul 20, 2014 at 4:13 PM, Sam Raker > wrote: >

positional + keyword args

2014-07-20 Thread Sam Raker
I'm trying to write a function that takes (up to) 4 arguments. I want to be able to supply every argument positionally, with a keyword or as a default, so that (f) (f 1) (f 1 2) (f 1 2 3) (f 1 2 3 4) (f 1 :b 2) (f 1 2 :c 3) ... (f :a 1 :b 2 :c 3 :d 4) are all equivalent. In Python, I could do t

Re: Protocol equivalent of Python's `repr`?

2014-07-13 Thread Sam Raker
y > > [1] http://gorilla-repl.org > [2] http://vimeo.com/89532785 > > > On Sunday, 13 July 2014 18:51:40 UTC+1, Sam Raker wrote: >> >> I'm working my way through an intro to Clojure book, and I just got to >> the section on protocols. I might be missing

Protocol equivalent of Python's `repr`?

2014-07-13 Thread Sam Raker
I'm working my way through an intro to Clojure book, and I just got to the section on protocols. I might be missing something/committing a category error, but I'm wondering if there's a way to change the way a protocol is represented in the repl, akin to redefining `__repr__`/`__str__` in Python

IO/memory bottlenecks

2014-06-27 Thread Sam Raker
I'm super new to Clojure, so apologies if I've missed something. I'm trying to use an agent to manage IO for code that involves reading a bunch of JSON files, doing some processing, then writing the contents to separate files. I'm using pmap to speed things up, but I've run into some memory ove