{"action":"created","issue":{"url":"https://api.github.com/repos/ramda/ramda/issues/2662","repository_url":"https://api.github.com/repos/ramda/ramda","labels_url":"https://api.github.com/repos/ramda/ramda/issues/2662/labels{/name}","comments_url":"https://api.github.com/repos/ramda/ramda/issues/2662/comments","events_url":"https://api.github.com/repos/ramda/ramda/issues/2662/events","html_url":"https://github.com/ramda/ramda/issues/2662","id":366593622,"node_id":"MDU6SXNzdWUzNjY1OTM2MjI=","number":2662,"title":"Add reduced support to reduceBy and reduceRight","user":{"login":"morgsmccauley","id":11974624,"node_id":"MDQ6VXNlcjExOTc0NjI0","avatar_url":"https://avatars3.githubusercontent.com/u/11974624?v=4","gravatar_id":"","url":"https://api.github.com/users/morgsmccauley","html_url":"https://github.com/morgsmccauley","followers_url":"https://api.github.com/users/morgsmccauley/followers","following_url":"https://api.github.com/users/morgsmccauley/following{/other_user}","gists_url":"https://api.github.com/users/morgsmccauley/gists{/gist_id}","starred_url":"https://api.github.com/users/morgsmccauley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morgsmccauley/subscriptions","organizations_url":"https://api.github.com/users/morgsmccauley/orgs","repos_url":"https://api.github.com/users/morgsmccauley/repos","events_url":"https://api.github.com/users/morgsmccauley/events{/privacy}","received_events_url":"https://api.github.com/users/morgsmccauley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-04T01:59:43Z","updated_at":"2018-10-05T08:48:31Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"This issue spawned off the back of #1766\r\n\r\nCurrently the only functions to support `reduced` are:\r\n- `reduce`\r\n- `reduceWhile`\r\n- `transduce`\r\n\r\nGiven that there are more reduce functions, it may be beneficial for these to also support `reduced`.\r\n\r\n`reduced` short circuiting is handled within `_reduce` by both `_iterableReduce` and `_arrayReduce`. At first, I attempted to abstract out the `reduced` logic from both these functions, but struggled to do so while maintaining a clean function api.\r\n\r\nGiven that I could not re-use the logic within `_reduce`, I looked at alternate `reduceRight` solutions which utilised `_reduce`.\r\nThis included creating a generator to read from the tail, leaving `_iterableReduce` to handle `reduced`, but this created too much of a performance overhead to be a viable solution. The cleanest solution would simply be to use `_reduce(flip(fn), acc, reverse(list))`, but again, the performance difference proved too large.\r\nThese comparisons along with a bunch of alternatives can be viewed [here](https://jsperf.com/ramda-array-reverse-comparison) if anyone is interested.\r\n\r\nThe only option I see left is to duplicate the `reduced` logic from `_reduce` and add this to both `reduceBy` and `reduceRight`. Here is the result:\r\n\r\nhttps://github.com/morgsmccauley/ramda/blob/23ca61621649378f5845aa5708f5d6f81a8ded60/source/reduceRight.js#L46-L57\r\n\r\nhttps://github.com/morgsmccauley/ramda/blob/23ca61621649378f5845aa5708f5d6f81a8ded60/source/reduceBy.js#L50-L62\r\n\r\nPersonally, I am not a big fan of this due to the repeated logic, but cant seem to find another solution.\r\n\r\nWhat are your thoughts on this? Does anyone else see an alternative? Would love a second input!"},"comment":{"url":"https://api.github.com/repos/ramda/ramda/issues/comments/427291867","html_url":"https://github.com/ramda/ramda/issues/2662#issuecomment-427291867","issue_url":"https://api.github.com/repos/ramda/ramda/issues/2662","id":427291867,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNzI5MTg2Nw==","user":{"login":"morgsmccauley","id":11974624,"node_id":"MDQ6VXNlcjExOTc0NjI0","avatar_url":"https://avatars3.githubusercontent.com/u/11974624?v=4","gravatar_id":"","url":"https://api.github.com/users/morgsmccauley","html_url":"https://github.com/morgsmccauley","followers_url":"https://api.github.com/users/morgsmccauley/followers","following_url":"https://api.github.com/users/morgsmccauley/following{/other_user}","gists_url":"https://api.github.com/users/morgsmccauley/gists{/gist_id}","starred_url":"https://api.github.com/users/morgsmccauley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morgsmccauley/subscriptions","organizations_url":"https://api.github.com/users/morgsmccauley/orgs","repos_url":"https://api.github.com/users/morgsmccauley/repos","events_url":"https://api.github.com/users/morgsmccauley/events{/privacy}","received_events_url":"https://api.github.com/users/morgsmccauley/received_events","type":"User","site_admin":false},"created_at":"2018-10-05T08:48:31Z","updated_at":"2018-10-05T08:48:31Z","author_association":"CONTRIBUTOR","body":"Thanks @CrossEye! Raised #2663 for this."}}
{"actor":{"display_login":"morgsmccauley"}}