I think I get your meaning, you have a vector with a vector nested in it--like [1 2 [1 5] 3 4]--right? If you want to get a value within a vector within a vector you can use the function "get-in". For example:<div>
<br></div><div>(def example-vec</div><div> [1 2 [1 5] 3 4])</div><div><br></div><div>(get-in example-vec [2 0])</div><div>>> 1</div><div><br></div><div>(get-in example-vec [2 1])</div><div>>> 5</div><div><br>
</div><div>The "get-in" function takes a collection and then a vector of what it should use on (what is equivalent to) recursive calls to "get". So the first example above is the same thing as doing (get 0 (get 2 example-vec)). If you had a nested vector within your nested vector, you could access those values directly by doing something like this:</div>
<div><br></div><div>(def example-vec2</div><div> [1 2 [1 [10 12] 5] 3 4])</div><div><br></div><div>(get-in example-vec [2 1 0])</div><div>>> 10</div><div><br></div><div>(get-in example-vec [2 1 1])</div><div>>> 12</div>
<div><br></div><div>Hope it helps.</div><div><br></div><div>-Omri</div><div><br><br><div class="gmail_quote">On Sun, Oct 9, 2011 at 6:41 PM, James Matheson <span dir="ltr"><<a href="mailto:jmatheson12@gmail.com">jmatheson12@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">This is a little basic but how do you access an element within a<br>
vector? I know (nth x) or (get x) will return the value at that index,<br>
but if I'm trying to get something where the value is [1, 5] how do I<br>
access 1 or 5 directly?<br>
<br>
Thanks in advance,<br>
Jamie<br>
_______________________________________________<br>
Cs254f11 mailing list<br>
<a href="mailto:Cs254f11@lists.hampshire.edu">Cs254f11@lists.hampshire.edu</a><br>
<a href="https://lists.hampshire.edu/mailman/listinfo/cs254f11" target="_blank">https://lists.hampshire.edu/mailman/listinfo/cs254f11</a><br>
</blockquote></div><br></div>