[ANN] Skyscraper 0.3

2020-02-18 Thread Daniel Janus
Hello! After more than 3 years in the making, I am proud to announce the 
release of Skyscraper 0.3.0, a scraping framework that helps you build 
structured dumps of whole websites.

Home: https://github.com/nathell/skyscraper/

Major improvements in 0.3.0:

   - Skyscraper has been rewritten from scratch to be asynchronous and 
   multithreaded, based on core.async.
   - Skyscraper now supports saving the scrape results to a SQLite database.
   - In addition to the classic scrape function that returns a lazy 
   sequence of nodes, there is an alternative, non-lazy, imperative interface (
   scrape!) that treats producing new results as side-effects.
   - reaver (using JSoup) is now available as an optional underlying HTML 
   parsing engine, as an alternative to Enlive.
   
See NEWS.md for a complete list.

I’m particularly happy about the database abilities of this release – for a 
glimpse of what it can do, see 
https://cljdoc.org/d/skyscraper/skyscraper/0.3.0/doc/database-integration.

Happy scraping!
– Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/1120591d-0cf2-4962-96d9-0ea5672b7b89%40googlegroups.com.


[ANN] Skyscraper 0.2.3

2016-11-17 Thread Daniel Janus
Dear Clojurians,

Skyscraper 0.2.3, an Enlive-based library for scraping information from 
whole sites in a structural way, has been released.  

Homepage / GitHub: https://github.com/nathell/skyscraper
Clojars: https://clojars.org/skyscraper

New in this release:

   - New feature: Custom parse functions.
   - New feature: Customizable error handling strategies.
   - Bugfix: :only now doesn’t barf on keys not appearing in seed.

Shameless plug: I will be giving a lightning talk about Skyscraper at 
Clojure eXchange 2016 in London. Come learn more!

Happy scraping,
--dj

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] Skyscraper 0.2.2

2016-05-06 Thread Daniel Janus
Skyscraper 0.2.2, an Enlive-based library for scraping information from 
whole sites in a structural way, has been released.  

Homepage / GitHub: https://github.com/nathell/skyscraper
Clojars: https://clojars.org/skyscraper

New in this release:

   - 
   - Skyscraper now uses Timbre for logging.
   - New cache backend: MemoryCache.
   - download now supports arbitrarily many retries.
   - A situation where a context has a processor but no URL now triggers a 
   warning instead of throwing an exception.

Happy scraping,
--dj

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Skyscraper 0.2.0, a library for scraping entire websites

2015-12-17 Thread Daniel Janus
Skyscraper 0.2.1, an Enlive-based library for scraping information from 
whole sites in a structural way, has been released.  

Homepage / GitHub: https://github.com/nathell/skyscraper
Clojars: https://clojars.org/skyscraper

New in this release:

   - New function: get-cache-keys.
   - scrape and friends can now accept a keyword as the first argument.
   - Cache keys are now accessible from within processors (under the 
   :cache-key key in the context).
   - New scrape options: :only and :postprocess.
   - scrape-csv now accepts an :all-keys argument and has been rewritten 
   using a helper function, save-dataset-to-csv.

This release coincides with the release of skyscraper-cache-mapdb 0.1.1, 
which features the following:

   - *print-length* and *print-level* are now rebound to nil upon 
   serialization, causing it to not break when you have these variables set in 
   the REPL.
   - New functions export-values and import-values.

Happy scraping,
-dj


   

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Skyscraper 0.2.0, a library for scraping entire websites

2015-10-03 Thread Daniel Janus
Skyscraper 0.2.0 has been released.  New in this release:

   - Skyscraper now supports pluggable cache backends.
   - The caching mechanism has been completely overhauled and Skyscraper no 
   longer creates temporary files when the HTML cache is disabled.
   - Support for capturing scraping results to CSV via scrape-csv.
   - Support for updating existing scrapes: new processor flag :updatable, 
   scrape now has an :update option.
   - New scrape option: :retries.
   - Fixed a bug whereby scraping huge datasets would result in an 
   OutOfMemoryError. (scrape no longer holds onto the head of the lazy seq 
   it produces).

Skyscraper's home is at https://github.com/nathell/skyscraper/ .

There is also a satellite project, skyscraper-cache-mapdb, which implements 
a MapDB backend for Skyscraper. skyscraper-cache-mapdb has just been 
released as version 0.1.0 to Clojars and the code is available at:

https://github.com/nathell/skyscraper-cache-mapdb/

Happy scraping,

-dj

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] Skyscraper 0.1.2, a library for scraping entire websites

2015-09-17 Thread Daniel Janus
Skyscraper 0.1.2 has been released. New in this release:

   - A processor can now return one context only. (Thanks to Bryan Maass.)
   - The processed-cache option to scrape now works as advertised.
   - New scrape option: :html-cache. (Thanks to ayato-p.)
   - New official defprocessor clauses: :url-fn and :cache-key-fn.
  - Note: these clauses existed in previous versions but were 
  undocumented.
   - All contexts except the root ones are now guaranteed to contain the 
   :url key.

Happy scraping,
-dj

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Skyscraper 0.1.0, a library for scraping entire websites

2015-08-24 Thread Daniel Janus
[Reusing the relatively new thread to publish information about new 
release:]

Skyscraper 0.1.1 is now out.  New in this release:

   - Processors (process-fn functions) can now access current context.
   - Skyscraper now uses clj-http https://github.com/dakrone/clj-http to 
   issue HTTP GET requests. 
  - Skyscraper can now auto-detect page encoding thanks to clj-http’s 
  decode-body-headers feature.
  - scrape now supports a http-options argument to override HTTP 
  options (e.g., timeouts).
   - Skyscraper’s output is now fully lazy (i.e., guaranteed to be 
   non-chunking).
   - Fixed a bug where relative URLs were incorrectly resolved in certain 
   circumstances.

Happy using,
-dj

W dniu wtorek, 11 sierpnia 2015 19:29:03 UTC+2 użytkownik Sergey Didenko 
napisał:

 Looks interesting, thank you.

 On Tue, Aug 11, 2015 at 5:00 PM, Daniel Janus nat...@gmail.com 
 javascript: wrote:

 Dear Clojurians,

 I'm happy to announce the availability of the first release of 
 Skyscraper, an Enlive-based library for structural scraping -- extracting 
 information from whole sites in a structural way.

 Homepage / GitHub: https://github.com/nathell/skyscraper
 Leiningen: [skyscraper 0.1.0]
 Clojars: https://clojars.org/skyscraper

 From the README:

 What is structural scraping? Think of Enlive. It allows you to parse 
 arbitrary HTML and extract various bits of information out of it: subtrees 
 or parts of subtrees determined by selectors. You can then convert this 
 information to some other format, easier for machine consumption, or 
 process it in whatever other way you wish. This is called scraping.

 Now imagine that you have to parse a lot of HTML documents. They all come 
 from the same site, so most of them are structured in the same way and can 
 be scraped using the same sets of selectors. But not all of them. There’s 
 an index page, which has a different layout and needs to be treated in its 
 own peculiar way, with pagination and all. There are pages that group 
 together individual pages in categories. And so on. Treating single pages 
 is easy, but with whole collections of pages, you quickly find yourself 
 writing a lot of boilerplate code.

 In particular, you realize that you can’t just wget -r the whole thing 
 and then parse each page in turn. Rather, you want to simulate the workflow 
 of a user who tries to “click through” the website to obtain the 
 information she’s interested in. Sites have tree-like structure, and you 
 want to keep track of this structure as you traverse the site, and reflect 
 it in your output. I call it “structural scraping”.

 This is where Skyscraper comes in.

 Happy using,
 --Daniel Janus

 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com 
 javascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] Skyscraper 0.1.0, a library for scraping entire websites

2015-08-11 Thread Daniel Janus
Dear Clojurians,

I'm happy to announce the availability of the first release of Skyscraper, 
an Enlive-based library for structural scraping -- extracting information 
from whole sites in a structural way.

Homepage / GitHub: https://github.com/nathell/skyscraper
Leiningen: [skyscraper 0.1.0]
Clojars: https://clojars.org/skyscraper

From the README:

What is structural scraping? Think of Enlive. It allows you to parse 
arbitrary HTML and extract various bits of information out of it: subtrees 
or parts of subtrees determined by selectors. You can then convert this 
information to some other format, easier for machine consumption, or 
process it in whatever other way you wish. This is called scraping.

Now imagine that you have to parse a lot of HTML documents. They all come 
from the same site, so most of them are structured in the same way and can 
be scraped using the same sets of selectors. But not all of them. There’s 
an index page, which has a different layout and needs to be treated in its 
own peculiar way, with pagination and all. There are pages that group 
together individual pages in categories. And so on. Treating single pages 
is easy, but with whole collections of pages, you quickly find yourself 
writing a lot of boilerplate code.

In particular, you realize that you can’t just wget -r the whole thing and 
then parse each page in turn. Rather, you want to simulate the workflow of 
a user who tries to “click through” the website to obtain the information 
she’s interested in. Sites have tree-like structure, and you want to keep 
track of this structure as you traverse the site, and reflect it in your 
output. I call it “structural scraping”.

This is where Skyscraper comes in.

Happy using,
--Daniel Janus

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Instaparse - thank you!

2014-06-13 Thread Daniel Janus
I'd like to join the thank-you chorus -- Instaparse rocks, period.

I'm using it to integrate my concordancing utility, Smyrna [1] with a 
POS-tagging engine for Polish originally written in C++; specifically, to 
parse the rules generated by the latter. I've given a talk on it this year 
at LambdaDays [2].

 [1]: https://github.com/nathell/smyrna/
 [2]: http://danieljanus.pl/lambdadays-2014 
http://danieljanus.pl/lambdadays-2014/#//

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Lambda: A lniux distro for clojurists

2012-05-28 Thread Daniel Janus
What *I* would very much like to see is something along the lines of 
http://www.informatimago.com/linux/emacs-on-user-mode-linux.html but with 
the JVM running Clojure directly on top of the Linux kernel. Plus some 
editor/IDE to hack comfortably (Clooj?).

This cannot be done easily since the stock JVMs require a number of 
libraries including the X stack, but a custom JVM could fix it. Not that 
it'd be exactly useful, but boy, what a hack value it would have.

-Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

[ANN] clj-tagsoup 0.3.0

2012-05-01 Thread Daniel Janus
Dear Clojurians,

I have released version 0.3.0 of clj-tagsoup [1], the HTML parser for 
Clojure. clj-tagsoup is a wrapper around TagSoup [2] and can parse 
arbitrary (potentially malformed) HTML (or XML) into Clojure data 
structures.

New in this release is the ability to lazily parse XML using TagSoup and 
clojure.data.xml.

Enjoy,
-- Daniel 

 [1]: http://github.com/nathell/clj-tagsoup
 [2]: http://home.ccil.org/~cowan/XML/tagsoup/

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: [ANN] clojure-py 0.1.0 Clojure on Python

2012-03-08 Thread Daniel Janus
I'm seeing it on Arch Linux as well, using both pip2 and easy_install-2.7.

Thanks,
Daniel

W dniu czwartek, 8 marca 2012, 12:00:24 UTC użytkownik tbc++ napisał:

 Congrat's on the release! I am getting the following error on my
 Macbook (running 64-bit Lion, Python 2.7.1) when trying to run sudo
 easy_install clojure-py:

 I've seen this once before, in Linux, I'll open a bug for it and see
 if we can get it ironed out.

 Timothy



-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

[ANN] clj-json-rpc 0.1: a Ring-compatible handler for JSON-RPC web services

2012-02-25 Thread Daniel Janus
Hi,

I've just released version 0.1 of clj-json-rpc to Clojars. clj-json-rpc is 
a Clojure library that makes it easy to create web services using the 
JSON-RPC protocol and Ring. Check it out 
at https://github.com/nathell/clj-json-rpc

Enjoy,
Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

objects with metadata inside eval -- bug?

2012-02-20 Thread Daniel Janus
Hello,

In Clojure 1.3 this works:

(eval `(let [f# ~(fn [x] (+ x 1))] f#))

This does not, failing with an ExceptionInInitializerError:

(eval `(let [f# ~(with-meta #(+ % 1) {:foo :bar})] f#))

Both work in Clojure 1.2.1.  Have I hit a regression bug?  If not, what is 
the rationale of this not working? 

Thanks,
Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: how to get font-lock to work in swank repl buffer

2012-01-20 Thread Daniel Janus
On Thursday, January 19, 2012 9:52:44 PM UTC, bsmith.occs wrote:
 

 Incidentally, what's with this strange form of let?

   (let (font-lock-mode) ;; - shouldn't this bind variables?
 (clojure-mode-font-lock-setup))

In Common Lisp (and presumably in Emacs Lisp as well), 'let' takes an 
additional pair of parens around each name/value pair. This allows for a 
shortcut: (let (a) body) is equivalent to (let ((a nil)) body).

Sorry for the offtopic,
- Daniel 

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Sort a vector and keep the elements' indexes

2012-01-06 Thread Daniel Janus
(sort-by second (map-indexed vector [25 5 70]))

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Alternative structures to arrays?

2011-12-22 Thread Daniel Janus


On Thursday, December 22, 2011 3:35:35 PM UTC, Tassilo Horn wrote:

 Brian Hurt bhu...@gmail.com writes:

 Hi Brian,

  Vectors are actually a great trade-off, giving you almost the same
  access and memory costs arrays do, but with all the advantages of
  being immutable (multi-threaded goodness).

 On the other hand, you can have arrays of primitives but no vector of
 primitives.  

This is not quite correct: see vector-of.

Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: deprecating butlast?

2011-11-24 Thread Daniel Janus

On Wednesday, November 23, 2011 10:42:13 PM UTC, Nils Bertschinger wrote:
 

 It solves a
 common problem, namely to drop the last element of a sequence and
 reads better in this case than the equivalent idiom using drop-last.

I don't quite get it. How does (butlast x) read better than (drop-last x)?

(Granted, these two calls have slightly different semantics, the difference 
being laziness. However, the non-lazy version should not normally be 
required, or else we should have non-lazy versions of map, filter etc.)

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

*print-dup* and struct maps

2011-11-22 Thread Daniel Janus
Hi, 

I've encountered this behaviour of *print-dup*:

user (defstruct foo :field)
#'user/foo
user (binding [*print-dup* true] (pr-str (struct foo 10)))
#=(clojure.lang.PersistentStructMap/create {:field 10})
user (read-string (binding [*print-dup* true] (pr-str (struct foo 10
java.lang.IllegalArgumentException: No matching method found: create

with both Clojure 1.2.1 and 1.3.0.

I've been wondering if this could be called a bug. Obviously, in general 
*print-dup* cannot work with struct maps, because the structure needs to be 
defined beforehand. It seems inappropriate, however, that pr-str emits an 
invalid expression that can't then be read back: either this should fail 
while printing (with the error message along the lines of Cannot print 
struct maps when *print-dup* is true), or work iff the structure is 
defined when reading.

Should this be considered a bug?

On a side note: are struct maps deprecated, or are they going to be? It 
seems to be the concensus that their usage is discouraged, yet they are not 
marked as deprecated in the core code.

Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

deprecating butlast?

2011-11-22 Thread Daniel Janus
Hi,

Why keep both butlast and drop-last in clojure.core? The latter has the 
advantage that it's lazy and can drop off more than one element from the 
end of a seq. In contrast, I can't think of any advantage of butlast, 
except that it seems to be slightly (ca 20%) faster than (doall (drop-last 
x)). Wrapping drop-last in a doall should not be normally necessary, though.

Should butlast be deprecated?

Thanks,
Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Odp: Re: FleetDB or other NoSQL store for Clojure?

2011-07-17 Thread Daniel Janus


 As far as I know, the only NoSQL DB supporting transactions right now 
 is Redis. It also satisfies the rest of your points (well, I'm not 
 sure if Redis run on windows...). 


+1 for Redis -- we are using it in production, in fact it's a central piece 
of 
our architecture, and so far it's been working out splendidly. 

There are some wrappers for Cojure around, for example this one: 

 https://github.com/ragnard/redis-clojure


That one seems to be no longer maintained. We have encountered
problems with it, so I have a couple of unofficial patches at

https://github.com/nathell/redis-clojure

Be sure to use the clojure-1.2 branch unless you are working with an ancient 
version
of Clojure; there are also unofficial releases at Clojars: 
http://clojars.org/org.clojars.nathell/redis-clojure

Another option is clj-redis by Mark McGranaghan. It's currently a bit 
lacking in
functionality (at least it was a couple of months ago), it uses Jedis 
whereas
redis-clojure is 'pure' Clojure; definitely worth checking out.
 
Best,
- Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Odp: Unable to resolve var: subset? in this context (NO_SOURCE_FILE:1)

2011-07-14 Thread Daniel Janus
subset? is in the clojure.set namespace, so you must (use 'clojure.set) 
before you can
use subset? unqualified.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Odp: Re: Convert HTML to Vector Notation

2011-07-12 Thread Daniel Janus
Hey, thanks for recommending my library! :-)

Best,
Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Build tool for mixed Clojure/Java projects

2011-07-04 Thread Daniel Janus
 2) Network independence. I often work without Internet access, and I  
 don't want to be blocked at some point because some build tool wants  
 to access some repository to see if my version is still current.

For the record, this is easily doable with both Leiningen and Cake
(which both use Maven under the hood). One just has to create
a ~/.m2/settings.xml with the following content:

settings xmlns=http://maven.apache.org/SETTINGS/1.0.0;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd;
   offlinetrue/offline
/settings

Best,
- Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.core/some expected behaviour

2011-04-02 Thread Daniel Janus
Hi Andreas,

 (some #{:fred} [:fred :barney])
 = :fred
 This expected.
 Would one be write to expect
 (some #{:fred} {:fred flinstone :barney rubble})
 to return
 = :fred
 as well?

(some #{:fred} (keys {:fred flinstone :barney rubble}))

will get you what you need.

Best,
Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.core/some expected behaviour

2011-04-02 Thread Daniel Janus
On 3 Kwi, 07:37, Andreas Kostler andreas.koestler.le...@gmail.com
wrote:

 Hi Daniel,
 Thanks for your reply. I know how to get to :fred.
 I'm just wondering why some wouldn't work on maps.

Well, `some' finds an element in a seq that satisfies the given
predicate, and seq'ing a map will get you a sequence of key/value
pairs. So, using a set as a predicate, you could test whether a given
key/value pair exists in a map:

  (some #{[:barney rubble]} {:fred flinstone :barney rubble})

So it does work on maps, albeit not in the way you'd expect it to.

Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


locals clearing

2011-01-30 Thread Daniel Janus
Hi,

I've recently heard about the locals clearing feature of Clojure 1.2 (from a 
recent post by Ken Wesson), and decided to test-drive it. Here is a 
contrived example:

(defn garbage []
  (make-array Byte/TYPE 10485760))

(defn -main [ args]
  (let [a (garbage)
b (garbage)
c (garbage)
d (garbage)
e (garbage)
f (garbage)
g (garbage)
h (garbage)]
(println OK)))

Now, when I build this with Leiningen and try to run under -Xmx20M or so, it 
bombs out on me with an OOME. Changing the let to a bunch of nested lets 
doesn't help, nor does migrating to Clojure 1.3alpha4. 

Shouldn't the locals clearing feature detect that each of the a-h locals is 
no longer needed and clear them right after allocation? Is this a 
misconception on my part about how this works? Or is something weird going 
on here? 

Thanks,
-Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: get the total memory used by a data structure?

2010-12-23 Thread Daniel Janus
On 23 Gru, 05:51, Robert McIntyre r...@mit.edu wrote:

 I think it would be really cool to have a function that gives the
 total number of bytes that a data structure consumes.

Here is a tiny utility I wrote some time ago; it's not very accurate,
but
might come in handy:

https://gist.github.com/417669

best,
Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Erlang-esque bit syntax in Clojure?

2010-12-16 Thread Daniel Janus
Hi Daniel,

I'm fairly certain this is not exactly what you're looking for, but
it's somewhat related and it might give you a fuller image -- my
tiny clj-bitfields library:

  https://github.com/nathell/clj-bitfields

Best,
Daniel Janus

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: mapmap?

2010-12-07 Thread Daniel Janus
While on the topic, I'd like to raise a naming issue.

The 'mapmap' function seems to be a recurring theme (see, e.g.,
http://tech.puredanger.com/2010/09/24/meet-my-little-friend-mapmap/)
and many Clojure projects include one -- Incanter comes to mind. My
project used to, too. But we found out that the name mapmap has its
deficiencies.

First, it conflates the two senses of the word map (1. noun -- an
object implementing IPersistentMap; 2. verb -- to apply a function to
each element of a collection, producing a new one) by putting them
right next to each other. This impairs code readability: I once found
myself typing (mapmap #(map ... ) ...) -- it's unobvious at first
sight which map is used in which sense.

Second, all these implementations of mapmap floating around are
mutually incompatible, which partly stems from the fact that it is
unclear from the name what the argument of mapmap should be. Should it
be a value-value function? Or should it take two arguments, a key and
a value? Or should it take a [key value] pair?

Actually, each one of these flavors is useful on different occasions.
So to differentiate between them, we've now dropped mapmap and use
transform-v and transform-kv instead. Here they are, with docstrings:

(defn transform-kv
  Transforms each entry in a map with f and returns the resulting
map.
f should take and return a key/value pair.  Similar to
clojure.contrib.generic.functor/fmap, but can take keys into account.
Works on any seq of pairs (not necessarily maps), always returning
maps.
  [f x]
  (into {} (map (fn [[k v]] (f k v)) x)))

(defn transform-v
  Like transform-kv, but takes a value-value function, leaving keys
intact.
  [f x]
  (into {} (map (fn [[k v]] [k (f v)]) x)))

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Bug with map keys containing quotes in clojure.contrib.json

2010-09-30 Thread Daniel Janus
Hi,

c.c.json/json-str seems to handle maps with keys containing quotes
incorrectly:

 (println (json-str {\ 1}))
{:1}

...while I (and my parsers) would expect {\:1}.

I'd much rather report this on Assembla than here, but I seem to be
needing a CA to post a ticket there, and I'm in way too big hurry to
sign the CA now... I have the feeling that Clojure makes it too
difficult to just report a bug in it or Contrib (as opposed to
submitting a fix).

Thanks,
- Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Bug with map keys containing quotes in clojure.contrib.json

2010-09-30 Thread Daniel Janus
I forgot to add that this happens both with contrib 1.2.0 and 1.3-
alpha1.

Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Bug with map keys containing quotes in clojure.contrib.json

2010-09-30 Thread Daniel Janus
On 30 Wrz, 20:46, Steve Purcell st...@sanityinc.com wrote:

 You can file the bug as a support ticket without a CA here:

 http://www.assembla.com/spaces/clojure/support/tickets

Thanks, I've reported it as a contrib support ticket. I wasn't aware
of this functionality.

Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: 1.2 contrib shuffles

2010-08-30 Thread Daniel Janus
On 28 Sie, 07:00, Stuart Sierra the.stuart.sie...@gmail.com wrote:
 On Aug 27, 3:42 pm, B Smith-Mannschott bsmith.o...@gmail.com wrote:

  This thread got me thinking that when a namespace is partially promoted to
  Clojure proper, it might be good to provide a reduced version of the old
  namespace, providing just the functionality that was not promoted as an
  alternative to complete removal.

 Speaking as their author, c.c.io and c.c.str* should be removed
 completely.  If a function or macro didn't get promoted to Clojure
 proper, it is because it was poorly written or redundant.

Could you elaborate?  What is redundant or poor about with-out-writer
and with-in-reader?

Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


1.2 contrib shuffles

2010-08-27 Thread Daniel Janus
Hi,

so I finally got around to port my app to Clojure 1.2 and got confused
about the contrib shuffles.

There's clojure.java.io and clojure.contrib.io. The docs on the latter
says that most of the functions defined in there are deprecated, and
one should use clojure.java.io instead. But clojure.java.io lacks some
of the very useful macros and function I'm using, like with-in-reader,
with-out-writer, slurp*, to name but a few; clojure.contrib.io does
have them, but it relies on its own primitives, instead of building on
clojure.java.io. So in a way I'm committed to using (if indirectly)
code that is already deprecated. What are the plans for contrib
development in this case?

On a side note: shouldn't slurp* and slurp be unified somehow in a
future release?

Also, contrib 1.2's str-utils contains the following confusing comment
at the very top:

;; DEPRECATED in 1.2: Promoted to clojure.java.string. Note that
;; many function names and semantics have changed

whereas there's no such thing as clojure.java.string.

Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: looking for a simpler implementation of a function I'm using

2010-08-08 Thread Daniel Janus
Here's my take using my clj-iter (http://github.com/nathell/clj-iter):

(defn partition-when
  [pred coll]
  (iter (for x in coll)
(for p = (when x (pred x)))
(for y initially () then (if p (list x) (cons x y)))
(collect (reverse y) if p)
(finally-collect (reverse y

Hopefully it's readable.

Best,
Daniel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


how to await for a potentially erring agent?

2010-06-11 Thread Daniel Janus
Hi all,

What is the best way to await for an agent in the following way:
1. if it's running a computation, wait until either it runs to
completion or throws an exception,
2. if it has errors, do nothing (because the computation has already
been terminated by an exception)?

I'm on Clojure 1.1. I currently have something along these lines:

(send-off agent my-computation)
(await agent)
(if (agent-errors agent)
  ;; handle these errors
  (clear-agent-errors agent))

Now, this sometimes works and sometimes doesn't get past the call to
await. Clearly, there's a race condition here: if the computation
happens to bomb out with an error before await is called (case 2
above), then the 'send' fails to run (which await calls under the
hood):

Exception in thread main java.lang.RuntimeException: Agent has
errors
at clojure.lang.Agent.dispatch(Agent.java:145)
at clojure.core$send__4845.doInvoke(core.clj:1351)
at clojure.lang.RestFn.invoke(RestFn.java:430)
at clojure.core$await__5254.doInvoke(core.clj:2114)

I might check whether agent has errors before I call await, but I fear
introducing another, more subtle race condition (what if the error
occurs between agent-errors and await?)

How best to cope with this?

Best regards,
Daniel Janus

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


ANN: clj-tagsoup

2010-03-30 Thread Daniel Janus
Hi all,

I would like to announce clj-tagsoup, a simple cl-html-parse workalike
for Clojure.

A quick example:

(parse http://example.com;)
= [:html {}
  [:head {}
 [:title {} Example Web Page]]
  [:body {}
 [:p {} You have reached this web page by typing
\example.com\,\n\example.net\,\n  or \example.org\ into your web
browser.]
 [:p {} These domain names are reserved for use
in documentation and are not available \n  for registration. See 
 [:a {:shape rect, :href http://www.rfc-
editor.org/rfc/rfc2606.txt} RFC \n  2606]
 , Section 3.]]]

The code is on http://github.com/nathell/clj-tagsoup. I've pushed it
to Clojars, too.

Best regards,
Daniel Janus

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

To unsubscribe from this group, send email to 
clojure+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


Re: Another closure available

2009-11-08 Thread Daniel Janus

On 8 Lis, 08:11, pmf phil.fr...@gmx.de wrote:

  Hmm, someone else has made another closure available :).

 http://googlecode.blogspot.com/2009/11/introducing-closure-tools.html

 There's also Clozure Common Lisp [1], which is conceptually closer to
 Clojure.

There's also a web browser written in CL called Closure
(http://common-lisp.net/project/closure/)
--~--~-~--~~~---~--~~
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



[ANN] clj-iter, an iteration macro for Clojure inspired by Common Lisp's Iterate

2009-11-05 Thread Daniel Janus

Dear all,

I am happy to announce the public availability of clj-iter, an Iterate-
like iteration macro. It is free (available under the terms of MIT
license) and can be found on GitHub: http://github.com/nathell/clj-iter

The design goal was to keep it as simple as possible, and make it
blend well with the rest of Clojure.  In
contrast to cl-loop, which uses mutable bindings, clj-iter has a
functional flavour, and macroexpands to the kind of code you would
write manually using loop/recur.  It is also very simple, having a
fraction of Iterate's functionality, but I hope even the little there
is will be sufficient in many cases.

To avoid citing the entire README blurb, I'll just give you some
examples:

(iter (for x in [31 41 59 26])
  (for y from 1)
  (collect (+ x y)))
== (32 43 62 30)

(iter (for s on [1 2 3 4 5])
(for q initially () then (cons (first s) q))
(collect (cons (first s) (concat (take 2 (rest s)) (take 2
q)
== ((1 2 3) (2 3 4 1) (3 4 5 2 1) (4 5 3 2) (5 4 3))

Please let me know whether it is of any use to you.  Feedback, and
especially patches, are more than welcome.
--~--~-~--~~~---~--~~
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clj-iter, an iteration macro for Clojure inspired by Common Lisp's Iterate

2009-11-05 Thread Daniel Janus

On 6 Lis, 02:02, John Harrop jharrop...@gmail.com wrote:
 On Thu, Nov 5, 2009 at 7:03 PM, Daniel Janus nath...@gmail.com wrote:
  To avoid citing the entire README blurb, I'll just give you some
  examples:

     (iter (for x in [31 41 59 26])
           (for y from 1)
           (collect (+ x y)))
     == (32 43 62 30)

     (iter (for s on [1 2 3 4 5])
         (for q initially () then (cons (first s) q))
         (collect (cons (first s) (concat (take 2 (rest s)) (take 2
  q)
     == ((1 2 3) (2 3 4 1) (3 4 5 2 1) (4 5 3 2) (5 4 3))

 I hate to be the party-pooper in this bunch

On the contrary, criticism is most welcome too.  Especially when the
comments show a way of solving a problem (as in the case of the
sliding window) I would never have thought of. Thank you (and also to
Kyle for offering up another variant)!

 but what's the advantage over:

 (map + [31 41 59 26] (iterate inc 1))

 and

 (let [s (take-while identity (iterate next [1 2 3 4 5]))]
   (map #(concat (cons (first %1) (concat (take 2 (rest %1)) (take 2 %2
     s
     (reductions #(cons (first %2) %1) () s)))

One possible answer is clarity.  It's mentally easier for me to parse
the clj-iter version than either alternative versions proposed.
Certainly, it is a matter of personal taste, but then again, you don't
have to use it if you don't want to.

As another example, consider multiplying the first 42 elements of a
list of numbers by 42, and leaving the rest unchanged. It's much more
straightforward for me to write (and then read)

(iter (for x in lst)
 (for i from 0)
 (collect (if ( i 42) (* x 42) x)))

than something along the lines of

(map (fn [[i x]] (if ( i 42) (* x 42) x))
   (map vector (iterate inc 0) lst))

Thanks again,
--Daniel
--~--~-~--~~~---~--~~
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



rebinding fn definitions not effective in lambdas?

2009-10-05 Thread Daniel Janus

Dear Clojurians,

Consider the following three simple functions:

(defn foo [] 42)
(defn bar [] 44)
(defn baz [s] (map (fn [_] (foo)) s))

Now let's rebind foo to bar:

user= (binding [foo bar] (foo))
44 ;; Just as I expected.
user= (binding [foo bar] (baz [1 2 3]))
(42 42 42) ;; while I would expect (44 44 44).

Am I missing something here?

Thanks,
-Daniel

--~--~-~--~~~---~--~~
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: java 1.4 class files

2009-07-29 Thread Daniel Janus

I'd try to first compile Clojure to 1.5 bytecode, then translate it to
1.4 using Retroweaver (http://retroweaver.sourceforge.net/).  I don't
know whether that'll work, though, since I think the Clojure compiler
generates and loads bytecode at runtime.  You might need to patch
Clojure to somehow squeeze retroweaving between the compiling and
loading phases.

--~--~-~--~~~---~--~~
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



inlining bitwise operations?

2009-07-29 Thread Daniel Janus

Hello,

Is there any reason for some of the bitwise functions (bit-and-not,
bit-clear, bit-set, bit-flip, bit-test, bit-shift-left and bit-shift-
right) not having inline variants?

Thanks,
Daniel

--~--~-~--~~~---~--~~
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Confusion with namespaces and SLIME

2009-07-28 Thread Daniel Janus

 The following steps should show the problem I'm having:

[...]

This sequence works perfectly well for me with SLIME 2009-07-15,
clojure-mode 8c333628bf507749dd78b312333130b00e6ec06f, swank-clojure
6cd3057d48e00da485cdf43b2b170816e5187c40, Emacs 22.2.1 (on Ubuntu
9.04), and both Clojure 1.0.0 and current git.  Perhaps you should try
upgrading your setup?

Best,
Daniel Janus

--~--~-~--~~~---~--~~
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Bitfields access in Clojure

2009-07-24 Thread Daniel Janus


  Up to eight elements in a literal map are stored
  as array-map. An array-map keeps the key ordering.
  For more elements the map becomes a hash-map,
  which does not keep the key ordering.

 I assume that's an implementation detail that one could not rely on,
 though, right?

Yeah, I guess so, and thanks to Paul and Meikel for pointing that out
--
I made the obvious mistake of assuming this is always going to work...

I'm going to change the API to replace the maps with vectors of
alternating
symbols and integers, which will make the ordering explicit.

Thanks once again!
Daniel Janus

--~--~-~--~~~---~--~~
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Bitfields access in Clojure

2009-07-22 Thread Daniel Janus

On 22 Lip, 09:52, Timothy Pratley timothyprat...@gmail.com wrote:
 Could you give a more detailed example to illustrate what this means?

    (with-bitfields arr 0 {last 1, term 1, dest 22, char 8}
      [last term dest char])

Perhaps a good illustration will be what it macroexpands to:

(let [last (+ (bit-and (aget arr (unchecked-add 0 0)) 1))
  term (+ (bit-shift-right (bit-and (aget arr (unchecked-add 0 0))
3) 1))
  dest (+ (bit-shift-right (bit-and (aget arr (unchecked-add 0 0))
255) 2)
  (bit-shift-left (bit-and (aget arr (unchecked-add 0 1))
255) 6)
  (bit-shift-left (bit-and (aget arr (unchecked-add 0 2))
255) 14))
  char (+ (bit-and (aget arr (unchecked-add 0 3)) 255))]
  [last term dest char])

The background is that in C99, you can declare structures like:

struct foo {
   uint32_t last:1;
   uint32_t term:1;
   uint32_t dest:22;
   uint32_t char:8;
};

which means that each of the fields is only that many bits long (e.g.
last can only hold values 0 and 1, while dest can range from 0 to
4194303).  Such a structure takes up 1+1+22+8 = 32 bits = 4 bytes in
memory.  It can also be written to disk, and clj-bitfields gives you a
way to read it back and access the individual fields.

Best regards,
Daniel Janus

--~--~-~--~~~---~--~~
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Bitfields access in Clojure

2009-07-21 Thread Daniel Janus

Dear list,

Having a free day on my hands, I finally got around to writing some
nontrivial code in Clojure. The result happens to be a library that I
hope might be useful to someone else besides me. It's called clj-
bitfields and consists of one macro, with-bitfields, that allow you to
say things like:

  (with-bitfields arr 0 {last 1, term 1, dest 22, char 8}
[last term dest char])

where `arr' is a Java array of bytes, and the map denotes names of
symbols that will be
bound to bitfields of a packed structure with given length.

The code of clj-bitfields can be found at

   http://github.com/nathell/clj-bitfields/tree/master

It's MIT-licensed, so I would be happy to see it mentioned on
clojure.org/libraries.

Since this is my first Clojure library and I'm not fully accustomed
yet to doing things The Clojure Way, I'm pretty certain that some
things might have been done better. I would be extremely grateful if
someone had a look at this code and comments on how to make it more
Clojurish.

Thanks!
Daniel Janus

--~--~-~--~~~---~--~~
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Bitfields access in Clojure

2009-07-21 Thread Daniel Janus

Dear list,

[I apologize in advance if this gets posted twice.]

Having a free day on my hands, I finally got around to writing some
nontrivial code in Clojure. The result happens to be a library that I
hope might be useful to someone else besides me. It's called clj-
bitfields and consists of one macro, with-bitfields, that allow you to
say things like:

  (with-bitfields arr 0 {last 1, term 1, dest 22, char 8}
[last term dest char])

where `arr' is a Java array of bytes, and the map denotes names of
symbols that will be
bound to bitfields of a packed structure with given length.

The code of clj-bitfields can be found at

   http://github.com/nathell/clj-bitfields/tree/master

It's MIT-licensed, so I would be happy to see it mentioned on
clojure.org/libraries.

Since this is my first Clojure library and I'm not fully accustomed
yet to doing things The Clojure Way, I'm pretty certain that some
things might have been done better. I would be extremely grateful if
someone had a look at this code and comments on how to make it more
Clojurish.

Thanks!
Daniel Janus

--~--~-~--~~~---~--~~
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---