Assume d & w have the same length.
Assume load-file loads an indexed doc
Assume malformed? tests a doc
Assume process-doc takes a doc & word as an input (two args)

So something like this...

(map process-doc (filter malformed? (map (memoize load-file) d)) w)

Is this remotely close, or did I misinterpret your request?
Sean

On May 27, 2:11 pm, CuppoJava <patrickli_2...@hotmail.com> wrote:
> Hi,
> I have a little snippet of Java code that I want to express in
> Clojure. But all my attempts thus far have been much more unreadable
> than the equivalent Java. Some help would be greatly appreciated.
>
>     d and w are arrays of integers,
>     d: [0 0 0 0 0 1 1 1 1 2 2 3 3 3 3 3 4 4 ... ]
>     w: [1 2 3 1 4 1 2 2 1 4 5 1 2 1 3 3 1 1 ... ]
>
>     int doc = -1;
>     for(int i=0 i<w.length; i++){
>       //Load doc if not already loaded
>       if(doc != d[i]){
>         doc = d[i];
>         load(doc);
>       }
>
>       //Stop if doc is malformed
>       if(malformed(doc))
>         break;
>
>       //Process word
>       process(doc, w[i]);
>     }
>
> Thank a lot for your help and insight.
>   -Patrick

-- 
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

Reply via email to