Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure representing byte array

In java i would read the whole file in to byte array and do some processing with it. Now i want to implement the same algorithm in clojure.

What i am wondering is can i use a list instead of an array?

I know i can create array from clojure but what is the lisp way of handling this?

like image 767
Hamza Yerlikaya Avatar asked Jun 27 '09 04:06

Hamza Yerlikaya


1 Answers

If the file in question is very large, you should always consider using a memory mapped file. clojure.contrib.mmap offers some functions to deal with that.

I know i can create array from clojure but what is the lisp way of handling this?

I don't know about the Lisp way, but the Clojure way allows you to use the sequence functions on arrays, so you don't have to decide between efficient representation and comfortable handling (which in my opinion is one of the points that makes Clojure so pragmatic).

like image 62
pmf Avatar answered Oct 22 '22 00:10

pmf