On Jan 3, 7:06 pm, Timothy Pratley <timothyprat...@gmail.com> wrote:
> 2010/1/4 Tom Hicks <hickstoh...@gmail.com>:
>
> > Comments and code review welcome
>
> Hi Tom,
>
> Some interesting additions. Regarding sub-sequence it might also be
> written like so:
>
> (defn subseq2
>   [coll start end]
>   (take (- end start) (drop start coll)))
> ; (subseq2 [0 1 2 3 4] 1 3)
> ; = (1 2)

Good catch: that the inner let was not needed (a leftover from
development, which I missed). I've updated it in the gist.

I note that you've grasped the heart of the idea with your
very short version. All the other code is there to parallel
the functionality in 'subvec'. You can, for instance, say
(indexed-subseq v 4) to return everything after the 4th element.


> There is a clash with core's existing subseq function which is
> specifically for sorted collections. I realize you named it slightly
> differently but there is little to distinguish from the name what the
> difference is, which will lead me to confusing the two.

Yea, I agree but I couldn't think of a good name....I've renamed it
to 'indexed-subseq', but I'm still open to suggestions for a better
name.


> There are a
> few ways this could be resolved:
> 1) Allow core subseq to operate as you described on unsorted
> collections, and as it does now on sorted collections. This would make
> the signature of the function a little curly but seems reasonable.
> 2) Live with similar name. I can't think of anything that contrasts
> subseq appropriately.
> 3) Core subseq renamed to subsorted or find or search - Unlikely and
> undesirable.
> 4) Just use take and drop.

> In terms of hyphenation I believe Lisp and Clojure idioms tend to
> prefer hyphenating separate words, but sub is a conjunction so should
> not be hyphenated (e.g.: submarine yellow-submarine).

OK, I buy it :)....I've renamed it, as mentioned above.

Thanks for looking this over, I appreciate your suggestions.
     regards,
     -tom

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