{"action":"created","issue":{"url":"https://api.github.com/repos/nathanmarz/specter/issues/33","labels_url":"https://api.github.com/repos/nathanmarz/specter/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/nathanmarz/specter/issues/33/comments","events_url":"https://api.github.com/repos/nathanmarz/specter/issues/33/events","html_url":"https://github.com/nathanmarz/specter/issues/33","id":114193016,"number":33,"title":"How to use keypath?","user":{"login":"mstang","id":758952,"avatar_url":"https://avatars.githubusercontent.com/u/758952?v=3","gravatar_id":"","url":"https://api.github.com/users/mstang","html_url":"https://github.com/mstang","followers_url":"https://api.github.com/users/mstang/followers","following_url":"https://api.github.com/users/mstang/following{/other_user}","gists_url":"https://api.github.com/users/mstang/gists{/gist_id}","starred_url":"https://api.github.com/users/mstang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstang/subscriptions","organizations_url":"https://api.github.com/users/mstang/orgs","repos_url":"https://api.github.com/users/mstang/repos","events_url":"https://api.github.com/users/mstang/events{/privacy}","received_events_url":"https://api.github.com/users/mstang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-30T03:34:57Z","updated_at":"2015-10-31T14:34:57Z","closed_at":null,"body":"I have a question concerning keypath, I see how you created a param-compiled, but how do I pass it a list of params? The example shows (param-compiled :a :b :c), so how would I pass it a list (:a :b :c)? I have a \"path\" (i.e.\"/Shops/shop0001/cust0001\") that I can split into (Shops shop0001 cust0001), but how do I pass it to select/transform? I have tried map and apply but everything gives me errors back."},"comment":{"url":"https://api.github.com/repos/nathanmarz/specter/issues/comments/152740046","html_url":"https://github.com/nathanmarz/specter/issues/33#issuecomment-152740046","issue_url":"https://api.github.com/repos/nathanmarz/specter/issues/33","id":152740046,"user":{"login":"mstang","id":758952,"avatar_url":"https://avatars.githubusercontent.com/u/758952?v=3","gravatar_id":"","url":"https://api.github.com/users/mstang","html_url":"https://github.com/mstang","followers_url":"https://api.github.com/users/mstang/followers","following_url":"https://api.github.com/users/mstang/following{/other_user}","gists_url":"https://api.github.com/users/mstang/gists{/gist_id}","starred_url":"https://api.github.com/users/mstang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstang/subscriptions","organizations_url":"https://api.github.com/users/mstang/orgs","repos_url":"https://api.github.com/users/mstang/repos","events_url":"https://api.github.com/users/mstang/events{/privacy}","received_events_url":"https://api.github.com/users/mstang/received_events","type":"User","site_admin":false},"created_at":"2015-10-31T14:34:57Z","updated_at":"2015-10-31T14:34:57Z","body":"So, what I am trying to do is to create a function that I can pass a list of strings and a map to do a select or a transform. \r\n\r\nThe list of strings starts out as a path:\r\n\r\n    \"/Shops/shop0001/cust0001/veh0001/job0001\"\r\n\r\nI have helper functions to \"split\" the path into a list or vector of strings:\r\n\r\n    (println \"str/split:\" (str/split \"/Shops/shop0001/cust0001/veh0001/job0001\" #\"/\"))\r\n    (println \"map:\" (map s/keypath (split-path \"/Shops/shop0001/cust0001/veh0001/job0001\")))\r\n\r\nThe result of these is:\r\n\r\n    split-path: (shop0001 cust0001 veh0001 job0001)\r\n    str/split: [ Shops shop0001 cust0001 veh0001 job0001]\r\n\r\nThe map looks like:\r\n\r\n    results: {Shops {shop0001 {cust0001 {:path /Shops/shop0001/cust0001, :last-name Stang, :first-name Mark, veh0001 {:path /Shops/shop0001/cust0001/veh0001, job0002 {:path /Shops/shop0001/cust0001/veh0001/job0002, :job-id job0002}, :make Ford, job0001 {:path /Shops/shop0001/cust0001/veh0001/job0001, :job-id job0001}}, veh0002 {:path /Shops/shop0001/cust0001/veh0002, :make VW}}}}} \r\n\r\nSo, what I want to be able to do is to do something like:\r\n\r\n    (println \"select using map:\" (s/select [(map s/keypath (split-path \"/Shops/shop0001/cust0001/veh0001/job0001\"))] results))\r\n\r\nThe solutions I have found are:\r\n\r\n    (println \"five segments:\" (s/select [(s/keypath \"Shops\")(s/keypath \"shop0001\")(s/keypath \"cust0001\")(s/keypath \"veh0001\")(s/keypath \"job0001\")] results))\r\n\r\n    five segments: [{:path /Shops/shop0001/cust0001/veh0001/job0001, :job-id job0001}]\r\n\r\nand \r\n\r\n    (def param-compiled (s/comp-paths s/keypath s/keypath s/keypath s/keypath s/keypath))\r\n    (defn get-param-compiled [arg results]\r\n      (let [args (split-path arg)\r\n            arg0 (nth args 0)\r\n            arg1 (nth args 1)\r\n            arg2 (nth args 2)\r\n            arg3 (nth args 3)\r\n            arg4 (nth args 4)]\r\n        (s/select [(param-compiled arg0 arg1 arg2 arg3 arg4)] results)\r\n        ))\r\n    (println \"param-compiled:\" (get-param-compiled \"/Shops/shop0001/cust0001/veh0001/job0001\" results))\r\n    \r\n    param-compiled: [{:path /Shops/shop0001/cust0001/veh0001/job0001, :job-id job0001}]\r\n\r\nThis combination def param-compiled and the function get-param-compiled example shows how I created a function that takes five path segments and does a select.  I could continue that paradigm and create a def/function combination for each possible combination of arguments(i.e. 1 arg, two args, three, args, four args, five args, ...).  Even going as far as to pass in the function (i.e. s/select or s/transform). \r\n\r\nSo, I guess my question is how to pass in a list of strings/parameters to a select or a transform that represents the path to be acted on?\r\nIt seems that keypath isn't composable.  So, is there a better way?\r\n\r\nThe actual code for this is in https://github.com/mstang/pathdatabase.git, starting at line 108 if that helps."}}