Re: How to hide data representation with keywords for deftype accessor?

2010-04-11 Thread Konrad Hinsen

Sophie a écrit :


(deftype A [x]) gives me an accessor (:x anA)

Then I decide to change data representation of A without impacting
client code, but I don't seem able to define a function
(defn :x [anA] ...)

Should I be doing something different?


(:x anA) is not a special accessor function, it's just the standard use 
of a keyword as a lookup function for a map. Every type created by 
deftype behaves like a map with the field names as its keys. So if you 
change the field name, you ned to change the keyword used for retrieving 
the value.


If you want to provide an interface to your type that does not depend on 
your choice of field names, define your own accessor functions. For example


(deftype A [x])
(def get-A-value :x)

As long as you only use get-A-value in client code, you are free to 
change the field names in A.


Konrad


__ Information provenant d'ESET NOD32 Antivirus, version de la base des 
signatures de virus 5016 (20100410) __

Le message a été vérifié par ESET NOD32 Antivirus.

http://www.eset.com


--
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, reply using remove me as the subject.


Re: How to hide data representation with keywords for deftype accessor?

2010-04-11 Thread B Smith-Mannschott
On Sun, Apr 11, 2010 at 06:39, Sophie itsme...@hotmail.com wrote:
 (deftype A [x]) gives me an accessor (:x anA)

 Then I decide to change data representation of A without impacting
 client code, but I don't seem able to define a function
 (defn :x [anA] ...)

 Should I be doing something different?

It's not deftype that's giving you that accessor. All keywords, when
used as a function of an map try to look themselves up in said map.

(:somefield somemap)
;; means the same as:
(somemap :somefield)
;; provided somemap isn't nil

The things deftype defines behave like maps, which is why (:x anA)
works the way you expect.

You could defined accessor functions yourself and then use only those
to access the internals of your A instances. You'd then only have to
change the accessor function if the representation of A changed.
(deftype may also provide better ways of accomplishing this, I haven't
yet used it in practice.)

(defn x-of-A [anA] (:x anA))

// Ben

-- 
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, reply using remove me as the subject.


Re: How do I call Foo.class?

2010-04-11 Thread Lars Nilsson
On Fri, Apr 9, 2010 at 11:31 AM, dknesek doug.kne...@gmail.com wrote:
 How do I invoke Foo.class in Clojure?

 Specifically, I'm trying to convert this (working) Java to Clojure.

 service.getEntry(new URL(entryUrl), PortfolioEntry.class);

 When I do this:

 (def entry-url-str (str base-url portfolio-feed-url-suffix / id))  ;
 this works
 (def entry-url (new URL entry-url-str)) ; this works too
 (doto service
    ...
    (. getEnrty entry-url (class PortfolioEntry)))

 I get this:

 actual: java.lang.IllegalArgumentException: No matching method found:
 getEnrty for class com.google.gdata.client.finance.FinanceService

 Is seems like (class PortfolioEntry) doesn't resolve to the same
 type as PortfolioEntry.class.

 Any ideas?

Is getEnrty copy'n'pasted, or just mistyped in the email twice (in
code snippet and error message)?

Lars Nilsson

-- 
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, reply using remove me as the subject.


Haskell-style list functions

2010-04-11 Thread Yuto Hayamizu
Hi, all

I want some list functions in Haskell like mapAccumL in
clojure.contrib, because some sequence operations are difficult with
only functions in clojure.core and contrib.

Think about writing a function 'accum-seq', which takes a sequence of
numbers, and returns a sequence of numbers. Each element of returned
sequence is sum of numbers from the beginning to its position in given
sequence.

Ex)
user (accum-seq [1, 1, 1, 1, 1])
(1 2 3 4 5)
user (accum-seq [1, 2, 3, 4, 5])
(1 3 6 10 15)
user (accum-seq [1, -1, 1, -1, 1])
(1 0 1 0 1)

If you know any smart solutions with only currently available
functions, please tell me. I mean, 'smart' solutions have no explicit
'lazy-seq', recursion, and return a lazy sequence as a result.

This 'accum-seq' can be easily implemented by mapAccumL in Haskell
library. Here's my implementation of mapAccumL, and 'accum-seq' using
mapAccumL.

(defn accuml [f e coll]
  (if (empty? coll)
(empty coll)
(let [pair (f e (first coll))]
  (lazy-seq (cons pair (accumL f (first pair) (rest coll)))

(defn map-accuml [f e coll]
  (let [pair-coll (accumL f e coll)]
[(first (last pair-coll)),
 (map second pair-coll)]))

(defn accum-seq [coll]
  (map-accuml (fn [x y] [(+ x y), (+ x y)]) 0 coll))

I searched these kind of functions in Clojure API documentations, but
I could not find what I want. I hope these Haskell-style sequence
functions are included in clojure.contrib.


Anyway, I thank all of developers and contributors for creating such a
nice language. I really love it.


Yuto Hayamizu

Master's degree student at Kitsuregawa Laboratory
Department of Information and Communication Engineering
Graduate School of Information Science and Technology
University of Tokyo

-- 
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, reply using remove me as the subject.


How to separate code into different files

2010-04-11 Thread -r
Hi all,

I am a total newbie to Clojure. This is just my second day.

I was wondering how you split code into different files and use them
in clojure. For example if i have 2 folders dir1 and dir2 and dir1 has
file1.clj and dir 2 has file2.clj, how to call a function in file2
from file1. How to load these files?(similar to classpath in java)

-- 
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, reply using remove me as the subject.


Re: How do I call Foo.class?

2010-04-11 Thread Nurullah Akkaya

For analytics code which expects a call in Java like the following,

AccountFeed accountFeed = 
  analyticsService.getFeed(queryUrl, AccountFeed.class);

I had to do this,

(defn get-class [class]
  (Class/forName (str com.google.gdata.data.analytics. class)))

Class/forName will return a java.lang.Class then you can pass it to the
function,

(.getFeed service url (get-class AccountFeed))

Hope it helps...
-- 
Nurullah Akkaya
http://nakkaya.com

-- 
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, reply using remove me as the subject.


Re: How to separate code into different files

2010-04-11 Thread Nurullah Akkaya

Assuming you have the following file structure,

src/
src/tubes/
src/tubes/core.clj
src/tubes/download.clj
src/tubes/plugins/a.clj

Now to use plugin a from core,

(ns tubes.core
  (:use :reload-all tubes.plugins.a))

or to use download module from within plugin a,

(ns tubes.plugin.a
  (:use :reload-all tubes.download))

src/ needs to be in your classpath.

Regards,
-- 
Nurullah Akkaya
http://nakkaya.com

-- 
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, reply using remove me as the subject.


Re: Haskell-style list functions

2010-04-11 Thread Steve Purcell
On 10 Apr 2010, at 08:46, Yuto Hayamizu wrote:

 Hi, all
 
 I want some list functions in Haskell like mapAccumL in
 clojure.contrib, because some sequence operations are difficult with
 only functions in clojure.core and contrib.
 
 Think about writing a function 'accum-seq', which takes a sequence of
 numbers, and returns a sequence of numbers. Each element of returned
 sequence is sum of numbers from the beginning to its position in given
 sequence.
 
 Ex)
 user (accum-seq [1, 1, 1, 1, 1])
 (1 2 3 4 5)
 user (accum-seq [1, 2, 3, 4, 5])
 (1 3 6 10 15)
 user (accum-seq [1, -1, 1, -1, 1])
 (1 0 1 0 1)
 
 If you know any smart solutions with only currently available
 functions, please tell me. I mean, 'smart' solutions have no explicit
 'lazy-seq', recursion, and return a lazy sequence as a result.


Does this qualify as a 'smart' solution?

user (use '[clojure.contrib.seq-utils :only (reductions)])
nil
user (reductions + [1 2 3 4 5])
(1 3 6 10 15)
user 

-Steve

-- 
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, reply using remove me as the subject.


(apply partition coll1 coll2 ...)

2010-04-11 Thread Glen Rubin
I am working with a collection of sequences ...(e.g.
coll:
((/f /b /c /4 /5 /6 /3 /6 /f /4 /3 /2 /4 /5 /7 /3 /6) (/2 /b /c /4 /2 /
6 /3 /7 /f /4 /3 /2 /4 /5 /7 /3 /6)...)


I want to partition the sequences into groups of 4, but when I try the
following or something similar it fails saying either partition or
apply is being passed the wrong number of args.

 (map #(apply partition 4 %) coll)

-- 
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, reply using remove me as the subject.


Re: (apply partition coll1 coll2 ...)

2010-04-11 Thread Douglas Philips


On 2010 Apr 11, at 1:28 PM, Glen Rubin wrote:


I am working with a collection of sequences ...(e.g.
coll:
((/f /b /c /4 /5 /6 /3 /6 /f /4 /3 /2 /4 /5 /7 /3 /6) (/2 /b /c /4 / 
2 /

6 /3 /7 /f /4 /3 /2 /4 /5 /7 /3 /6)...)


I want to partition the sequences into groups of 4, but when I try the
following or something similar it fails saying either partition or
apply is being passed the wrong number of args.

(map #(apply partition 4 %) coll)


partition takes a sequence as a single parameter.
I think what you might want is something like this:

user= (def coll (list (range 10) (range 20 30) (range 40 50)))
#'user/coll
user= (map #(partition 4 %) coll)
(((0 1 2 3) (4 5 6 7)) ((20 21 22 23) (24 25 26 27)) ((40 41 42 43)  
(44 45 46 47)))

user=

-Doug

--
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, reply using remove me as the subject.


Re: Introduction to Monads in Clojure tech talk

2010-04-11 Thread alux
Thank you! Nice step by step intro.

Regards, alux


On 9 Apr., 06:04, Mike T. Miller jini...@gmail.com wrote:
 Adam Smyczek's Introduction to Monads video is now available.

 http://www.youtube.com/user/LinkedInTechTalks?feature=mhw5#p/u/0/ObR3...

 I'll work on getting an HD version up Friday.

 -mike

-- 
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, reply using remove me as the subject.


Re: How to hide data representation with keywords for deftype accessor?

2010-04-11 Thread Laurent PETIT
I would like to add another idea right out of my head:

When you say you want to hide from client code, juxtaposed to the
notion of (def)type, a little warning manifests itself in my head,
because as far as I understand them, types are there to provide
polymorphic implementations for protocols. So protocols should be the
primary targets as an API for your clients, not types.

By being easily used as maps, types are very powerful because you can
use all the default clojure functions on them, but inside your
libraries and the codebase you own, would you like to change the
internals of the type fields. For client code (client code as
code you can't modify or for which modification is almost impossible
without annoying someone else), better stick to
interfaces/protocols/factory functions/methods. (or, as the others
have said, explicit public API accessor functions).

HTH,

-- 
Laurent

2010/4/11 Sophie itsme...@hotmail.com:
 (deftype A [x]) gives me an accessor (:x anA)

 Then I decide to change data representation of A without impacting
 client code, but I don't seem able to define a function
 (defn :x [anA] ...)

 Should I be doing something different?

 Thanks!

 --
 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, reply using remove me as the subject.


-- 
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: My non-ELPA Emacs swank-clojure setup

2010-04-11 Thread Constantine Vetoshev
On Apr 8, 12:45 pm, Ævar Arnfjörð Bjarmason ava...@gmail.com wrote:
 If I have 10 Clojure projects I'm going to have 10 src/clojure.jar
 files. Do they really need to be there or could I just use the clojure
 that comes with my operating system (Debian)?

 When I hack Common Lisp I don't copy sbcl into all my projects, I just
 install it once globally. I'd like to do the same with clojure.

Although I'm with you about ELPA and preferring the traditional way to
install Emacs packages, I disagree on this point. I find it
counterproductive to think of Clojure and its distribution in the same
terms as Common Lisp's. It's easier to think of Clojure apps more like
Java apps which happen to use a much better language.

I actually prefer to have a lib/clojure-X.Y.Z.jar in my project. This
guarantees that, as long as the deployment machine has a Clojure-
supporting JVM, the app has no other system-level dependencies. It
also allows flexibility with trying out unreleased and unpackaged
versions of Clojure. This eliminates the hideous mess in most
distributions of having packages like python24, python25, python26,
python30 (and resulting things like python24-somelib and python26-
somelib).

-- 
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-arranging sub-partitions

2010-04-11 Thread Glen Rubin
I am working with a collection of sequences ...(e.g.
coll:
((/f /b /c /4 /5 /6 /3 /6 /f /4 /3 /2 /4 /5 /7 /3 /6...) (/2 /b /c /4 /
2 /
6 /3 /7 /f /4 /3 /2 /4 /5 /7 /3 /6...)...)

I want to rearange the sequence into groups of 4 where the later 2
elements are moved to the front for example:

(/f /b /c /4 /5 /6 /3 /6 /f /4 /3 /2 /4 /5 /7 /3 /6...)   I want to
transform it as follows:


(/c /4 /f /b /3 /6 /5 /6 /3 /2 /f /4)


I can break the collection of sequences up into groups of 4 as
follows:

(map #(partition 4 %) coll)


However I am having problems taking the resulting partitioned sequence
and further subdividing into groups of 2 before reversing the paired
groups order.

-- 
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, reply using remove me as the subject.


Re: My non-ELPA Emacs swank-clojure setup

2010-04-11 Thread Constantine Vetoshev
This thread encouraged me to post what I did to make swank-clojure
1.1.0 work with the the latest SLIME. It does not use any of swank-
clojure's automatic .jar downloading features (as of version 1.1.0).
These instructions won't work on Windows, but may work if you have
Cygwin.

Note that this sets up some Common Lisp installations. Delete those
lines if you don't want them.

If you already figured out how to put SLIME and swank-clojure on your
classpath, omit that part of the setup. See the comments.

Assumptions:
 - SLIME in ~/.emacs.d/site-lisp/slime
 - swank-clojure in ~/.emacs.d/site-lisp/swank-clojure
 - your project is laid out with a src/ directory containing your
actual code; it goes on the classpath
 - you want all .jar files in your project on your classpath
 - several directories, including classes/ and resources/, also get
added to your classpath
 - you have exactly one file called clojure-version-number.jar in
the resulting classpath; this becomes the version of Clojure launched
by SLIME

Instructions:
 - put the code below into your .emacs.d/init.el or .emacs file
 - use M-x clojure-project to launch SLIME; this is my variant of
swank-clojure-project, but it makes no assumptions about Maven,
magical downloads, ELPA, or anything else

Limitation:
 - slime-connect doesn't seem to work right; you have to launch
Clojure and your app using clojure-project

One more thing: swank-clojure 1.1.0 requires a tiny patch to work with
the latest SLIME. This patch seems to already be in swank-clojure's
master branch, but be aware of it: 
http://groups.google.com/group/swank-clojure/msg/01ff818359061a28

Could this be a good start to making swank-clojure both newbie-and-
ELPA-friendly and Emacs-graybeard-friendly?



;;; generic Emacs utility
;;; --

(defun add-subdirs-to-load-path (dir)
  (let ((default-directory (concat dir /)))
(normal-top-level-add-subdirs-to-load-path)))


;;; basic load-path setup
;;; --

(add-to-list 'load-path ~/.emacs.d/site-lisp)
(add-subdirs-to-load-path ~/.emacs.d/site-lisp)


;;; SLIME and swank-clojure
;;; --

(require 'slime-autoloads)
(add-to-list 'load-path ~/.emacs.d/site-lisp/slime/contrib)
;(slime-setup '(slime-fancy slime-asdf))
(slime-setup '(slime-repl))

(setq slime-net-coding-system 'utf-8-unix)

(setq slime-lisp-implementations
  '((acl  (/opt/acl/alisp))
(sbcl (/opt/sbcl/run-sbcl.sh))
(ccl  (/opt/ccl/dx86cl64

(defmacro defslime-start (name mapping)
  `(defun ,name ()
 (interactive)
 (let ((slime-default-lisp ,mapping))
   (slime

(defslime-start acl 'acl)
(defslime-start sbcl 'sbcl)
(defslime-start ccl 'ccl)
(defslime-start clojure 'clojure)

(setq swank-clojure-classpath '(~/.emacs.d/site-lisp/swank-clojure/
src))
(setq swank-clojure-extra-vm-args
  (list -server -Xms128M -Xmx512M -Dfile.encoding=UTF-8))

(autoload 'clojure-mode clojure-mode A major mode for Clojure t)
(add-to-list 'auto-mode-alist '(\\.clj$ . clojure-mode))
(require 'swank-clojure)

(add-hook 'slime-mode-hook
  (lambda ()
(setq slime-truncate-lines nil)
(slime-redirect-inferior-output)))

(defun clojure-slime-reset ()
  Helper function which resets Clojure in SLIME's list of
   implementations. Useful for changing Clojure's classpath.
  (setq slime-lisp-implementations
(cons `(clojure ,(swank-clojure-cmd) :init swank-clojure-init)
  (remove-if #'(lambda (x) (eq (car x) 'clojure))
 slime-lisp-implementations

(defun clojure-project-prompt (path)
  (interactive GProject path: )
  (list path))

(defun clojure-project (path)
  Set up Clojure classpath and other swank-clojure variables for
   the project with root at 'path'. Include all *.jar files under
   path. Also include 'classes' subdirectory.
  (interactive
   (let* ((dominating-file (locate-dominating-file buffer-file-name
   src/))
  (default-directory (if (and buffer-file-name dominating-
file)
 dominating-file
 default-directory)))
 (call-interactively 'clojure-project-prompt)))
  (when (and (fboundp 'slime-connected-p) (slime-connected-p))
(slime-quit-lisp)
(sleep-for 1)
(slime-kill-all-buffers))
  (flet ((clojure-jar-p (s) (string-match
 clojure\\(-[0-9a-f\\.]*\\)?\\.jar$
 s))
 (validate-path (p) (when (file-accessible-directory-p p)
  (list p
(let* ((src-path
(append
 (validate-path (expand-file-name src path))
 (validate-path (expand-file-name source path))
 (validate-path (expand-file-name code path
   (test-path

Re: re-arranging sub-partitions

2010-04-11 Thread ataggart
How about:

(defn foo [coll]
  (apply concat
(map (fn [[a b c d]] [c d a b])
  (partition 4 coll

On Apr 11, 3:25 pm, Glen Rubin rubing...@gmail.com wrote:
 I am working with a collection of sequences ...(e.g.
 coll:
 ((/f /b /c /4 /5 /6 /3 /6 /f /4 /3 /2 /4 /5 /7 /3 /6...) (/2 /b /c /4 /
 2 /
 6 /3 /7 /f /4 /3 /2 /4 /5 /7 /3 /6...)...)

 I want to rearange the sequence into groups of 4 where the later 2
 elements are moved to the front for example:

 (/f /b /c /4 /5 /6 /3 /6 /f /4 /3 /2 /4 /5 /7 /3 /6...)   I want to
 transform it as follows:

 (/c /4 /f /b /3 /6 /5 /6 /3 /2 /f /4)

 I can break the collection of sequences up into groups of 4 as
 follows:

 (map #(partition 4 %) coll)

 However I am having problems taking the resulting partitioned sequence
 and further subdividing into groups of 2 before reversing the paired
 groups order.

-- 
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, reply using remove me as the subject.


Re: re-arranging sub-partitions

2010-04-11 Thread ataggart
Or a more generic way:

(defn bar [n m coll]
  (when-let [s (seq coll)]
(let [a (take n s) b (take m (drop n s))]
  (concat b a (bar n m (drop (+ n m) s))


On Apr 11, 4:23 pm, ataggart alex.tagg...@gmail.com wrote:
 How about:

 (defn foo [coll]
   (apply concat
     (map (fn [[a b c d]] [c d a b])
       (partition 4 coll

 On Apr 11, 3:25 pm, Glen Rubin rubing...@gmail.com wrote:



  I am working with a collection of sequences ...(e.g.
  coll:
  ((/f /b /c /4 /5 /6 /3 /6 /f /4 /3 /2 /4 /5 /7 /3 /6...) (/2 /b /c /4 /
  2 /
  6 /3 /7 /f /4 /3 /2 /4 /5 /7 /3 /6...)...)

  I want to rearange the sequence into groups of 4 where the later 2
  elements are moved to the front for example:

  (/f /b /c /4 /5 /6 /3 /6 /f /4 /3 /2 /4 /5 /7 /3 /6...)   I want to
  transform it as follows:

  (/c /4 /f /b /3 /6 /5 /6 /3 /2 /f /4)

  I can break the collection of sequences up into groups of 4 as
  follows:

  (map #(partition 4 %) coll)

  However I am having problems taking the resulting partitioned sequence
  and further subdividing into groups of 2 before reversing the paired
  groups order.

-- 
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, reply using remove me as the subject.