(v 0) and the like already work when v is a vector. You can also do
something like this:

(defn proper-rem [a b]
  (if (neg? a)
    (dec (- b (rem (- (inc a)) b)))
    (rem a b)))

(defn at [v idx]
  (v (proper-rem idx (count v))))

(defn r [start end v]
  (let [c (count v)
        s (proper-rem start c)
        e (proper-rem end c)
        s2 (min s e)
        e2 (max s e)
    (subvec v s2 e2)))

(at '[a b c d e f g] -1)
g
(r '[a b c d e f g] -2 2)
[c d e]


On Wed, Jun 26, 2013 at 11:01 PM, Greg <g...@kinostudios.com> wrote:

> There is one feature that I really miss from newLISP and seems like it
> could be a natural extension to Clojure, and that is implicit indexing for
> lists and arrays.
>
> Clojure already has something similar in its use of keywords to act as
> functions that look themselves up in a map.
>
> This is basically the same concept, but using numbers instead. Implicit
> indexing creates a really elegant syntax for finding elements and ranges in
> a list or array. Here's an example:
>
> > (setf mylist '(a b c d e f g))
> (a b c d e f g)
> > (mylist 0)
> a
> > (mylist -1)
> g
> > (0 3 mylist)
> (a b c)
>
>
> Has this been considered already? Would this be something that could be
> added to the language syntax?
>
> Thanks for your consideration!
>
> Sincerely,
> Greg
>
> --
> --
> 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/groups/opt_out.
>
>
>

-- 
-- 
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/groups/opt_out.


Reply via email to