{"action":"created","issue":{"url":"https://api.github.com/repos/alehander42/zero-functional/issues/17","repository_url":"https://api.github.com/repos/alehander42/zero-functional","labels_url":"https://api.github.com/repos/alehander42/zero-functional/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/alehander42/zero-functional/issues/17/comments","events_url":"https://api.github.com/repos/alehander42/zero-functional/issues/17/events","html_url":"https://github.com/alehander42/zero-functional/pull/17","id":310332105,"number":17,"title":"Rework Zip + Reduce","user":{"login":"michael72","id":3508395,"avatar_url":"https://avatars2.githubusercontent.com/u/3508395?v=4","gravatar_id":"","url":"https://api.github.com/users/michael72","html_url":"https://github.com/michael72","followers_url":"https://api.github.com/users/michael72/followers","following_url":"https://api.github.com/users/michael72/following{/other_user}","gists_url":"https://api.github.com/users/michael72/gists{/gist_id}","starred_url":"https://api.github.com/users/michael72/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michael72/subscriptions","organizations_url":"https://api.github.com/users/michael72/orgs","repos_url":"https://api.github.com/users/michael72/repos","events_url":"https://api.github.com/users/michael72/events{/privacy}","received_events_url":"https://api.github.com/users/michael72/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-01T15:31:46Z","updated_at":"2018-04-08T08:00:10Z","closed_at":"2018-04-07T13:48:35Z","author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/alehander42/zero-functional/pulls/17","html_url":"https://github.com/alehander42/zero-functional/pull/17","diff_url":"https://github.com/alehander42/zero-functional/pull/17.diff","patch_url":"https://github.com/alehander42/zero-functional/pull/17.patch"},"body":"a small easter egg 🐰 🥚 \r\n\r\n+ rework `zip`\r\n   + zip also as 2nd, 3rd etc. command\r\n   + better support for non-indexable types `[]`\r\n   + performance should not be affected\r\n   + `zip(a,b,c)` is now (roughly) translated to \r\n       `a --> filter(idx <= minHigh) --> map(a[idx], b[idx], c[idx])` - which makes `zip` now more regular in handling\r\n+ rework `reduce`\r\n   + easier subcommands added (add, product, min, max)\r\n   + added \"Idx\" commands for `reduce` - e.g. `minIdx` to find the minimum element and its index\r\n+ benchmark: use of uint (as is also done in rust code) --> (slightly) better performance - because `mod` can be optimized to `and` by C compiler\r\n    + done same improvement to other nim file - performance here got much better (on my laptop) - but still not as good as zero-functional of course 😉 \r\n    + also set timing output to msec"},"comment":{"url":"https://api.github.com/repos/alehander42/zero-functional/issues/comments/379529527","html_url":"https://github.com/alehander42/zero-functional/pull/17#issuecomment-379529527","issue_url":"https://api.github.com/repos/alehander42/zero-functional/issues/17","id":379529527,"user":{"login":"michael72","id":3508395,"avatar_url":"https://avatars2.githubusercontent.com/u/3508395?v=4","gravatar_id":"","url":"https://api.github.com/users/michael72","html_url":"https://github.com/michael72","followers_url":"https://api.github.com/users/michael72/followers","following_url":"https://api.github.com/users/michael72/following{/other_user}","gists_url":"https://api.github.com/users/michael72/gists{/gist_id}","starred_url":"https://api.github.com/users/michael72/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michael72/subscriptions","organizations_url":"https://api.github.com/users/michael72/orgs","repos_url":"https://api.github.com/users/michael72/repos","events_url":"https://api.github.com/users/michael72/events{/privacy}","received_events_url":"https://api.github.com/users/michael72/received_events","type":"User","site_admin":false},"created_at":"2018-04-08T08:00:10Z","updated_at":"2018-04-08T08:00:10Z","author_association":"COLLABORATOR","body":"@alehander42 \r\nSorry, I did just too many changes - and doing it again 😊 - but it is really fun working with it.\r\nI have two major additions coming that I think are really great:\r\n- support for inline-iterator result making it possible to save the result of a command chain without the need of saving it to a sequence or other collection\r\n- user extensions - enable the user to add own commands (I'm just working on it in test.nim - will be cool 😎). The registering of the extension (without compile error) was the trickiest part - I finally got it working. I couldn't find any documentation of how that is possible done - so basically it looks like this:\r\n\r\nin zero-functional.nim (`zfExtension` is called on unknown commands - the definition was kind of difficult - leaving out anything could lead to funny compiler errors).\r\n```nim\r\n## This is the default extension complaining when a given function was not found.\r\nproc zfExtendBase(ext: ExtNimNode) : ExtNimNode {.compileTime.} =\r\n  assert(false, \"$1 is unknown, implement set 'zfExtension' to 'proc zfExtend(ext: ExtNimNode)' in a macro and provide your own implementation!\" % ext.node[0].repr)\r\n\r\n## If you want to extend `zero_functional` assign this variable in your own code to a function with the given signature.\r\n## The assignment has to be done during compile time - so for instance in a macro. \r\n## See `test.nim` for an example of how to do that.\r\nvar zfExtension* {.compileTime.} : proc(ext: ExtNimNode): ExtNimNode = zfExtendBase\r\n``` \r\nand in the user code:\r\n```nim\r\n## Used to implement own command \r\nproc zfExtend*(ext: ExtNimNode): ExtNimNode  {.compileTime.} =\r\n  case ext.label \r\n  of \"average\":\r\n    return ext.inlineAverage()\r\n  of \"intersect\":\r\n    return ext.inlineIntersect()\r\n  return nil\r\n\r\nmacro registerExtension(): untyped =\r\n  # set compile-time variable in zero-functional\r\n  zfExtension = zfExtend\r\n  zfAddSequenceHandlers(\"intersect\")\r\n```\r\n\r\n"}}
{"actor":{"display_login":"michael72"}}