It’s probably fine to do a linear search with .indexOf for small vectors, but
I’ll just say as a matter of style I prefer to use a couple of maps to hold
previous and next items. The maps are callable like functions, which I think
reads very nicely. Using your example data for ranks:
;; helpe
There's one important case where (coll n) is not the same as (get coll n) -
when coll is nil. In that case (get coll n) will return nil and (coll n)
will barf. I tend to use get in those cases because of this.
On 24 February 2015 at 08:50, Colin Yates wrote:
> A minor point (get col n) is the sa
Thanks Colin!
On Monday, February 23, 2015 at 12:55:12 PM UTC-7, Colin Yates wrote:
>
> Unless of course your whole example was to work with Protocols (he says as
> he notices the file is called protocols.clj in a protocols namespace) in
> which case - yep, that is fine :).
>
> On Monday, 23 Feb
Unless of course your whole example was to work with Protocols (he says as
he notices the file is called protocols.clj in a protocols namespace) in
which case - yep, that is fine :).
On Monday, 23 February 2015 19:51:00 UTC, Colin Yates wrote:
>
> A minor point (get col n) is the same as (col n)
A minor point (get col n) is the same as (col n).
It's more of a stylistic thing, but your use of protocols and
implementation is quite 'stateful'. I would have done the same with
vanilla maps:
(def employee [first-name last-name level]
{:first-name .})
(defn promote [{:keys [level] :as emp
This is for my language matrix project that has samples for 10 different
languages. My clojure knowledge is ok, but not really as great where I
would like it to be, therefore looking towards the community for help.
This example works, but it still has the feel of a lot of duplication, are
ther