specter

Latest version: 1.1.3
schmee 2018-10-30T07:28:16.007400Z

is there a better way to construct this path? maybe something involving recursive-path?

(defn tag-path [& tag-names]
  (apply
    concat
    (interpose
      [ALL]
      (map
        #(vector (selected? :tag (pred= %)) :value)
        tag-names))))

schmee 2018-10-30T07:30:11.008400Z

(tag-path "EA" "C1") => [(selected? :tag (pred= "EA")) :value ALL (selected? :tag (pred= "C1")) :value]

nathanmarz 2018-10-30T12:55:48.009300Z

@schmee dynamic navs will dramatically increase performance when tag-path is called with dynamic params (eg. a local variable)

nathanmarz 2018-10-30T12:55:52.009500Z

(defdynamicnav tag-path [& tag-names]
  (let [late-pred= (late-resolved-fn pred=)]
    (apply
      concat
      (interpose
        [ALL]
        (map
          #(vector (selected? :tag (late-pred= %)) :value)
          tag-names)
          ))))

nathanmarz 2018-10-30T12:56:51.009800Z

things like this are where you get huge speedup:

(defn f [a data]
  (select (tag-path a "b") data)
  )

schmee 2018-10-30T12:58:15.010300Z

nice! I haven’t delved into dynamic navs yet, I’ll check them out!

schmee 2018-10-30T12:58:31.010900Z

but would you say that is an OK way to write the tag-path function?

schmee 2018-10-30T12:58:52.011200Z

with all the interpose and apply and whatnot…

nathanmarz 2018-10-30T12:58:59.011300Z

not very much documentation on them, just this https://github.com/nathanmarz/specter/wiki/Specter%27s-inline-caching-implementation

nathanmarz 2018-10-30T12:59:10.011500Z

yes, it's fine

nathanmarz 2018-10-30T12:59:23.011900Z

all that logic only ever executes once per callsite

nathanmarz 2018-10-30T12:59:26.012100Z

because of dynamicnav

schmee 2018-10-30T12:59:47.012400Z

excellent, thanks for the help as always

nathanmarz 2018-10-30T13:00:49.012800Z

you've now delved into the most advanced part of specter ;)

nathanmarz 2018-10-30T13:00:59.013100Z

let me know if you have questions

schmee 2018-10-30T13:01:18.013300Z

will do!

schmee 2018-10-30T21:37:54.013900Z

is there any way to get access to collected values in view?

nathanmarz 2018-10-30T22:02:19.014300Z

@schmee no, but it's easy to make a custom navigator with that functionality

nathanmarz 2018-10-30T22:02:23.014500Z

see defrichnav

schmee 2018-10-30T22:36:49.014800Z

:thumbsup: