Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clojure - access element of 2d vector [duplicate]

Tags:

clojure

if I have a 2d vector like this:

[[1 2] [3 4] [5 6]]

Is this the best way to access an element at a co-ordinate [0, 0]

(get (get v 0) 0)

Or is there a better way?

like image 273
dagda1 Avatar asked Nov 26 '25 16:11

dagda1


1 Answers

Use get-in to access a nested structure:

(get-in v [0 0]) ; => 1
like image 98
Andrew Marshall Avatar answered Nov 28 '25 15:11

Andrew Marshall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!