{"action":"created","comment":{"url":"https://api.github.com/repos/ramda/ramda/pulls/comments/32331012","id":32331012,"diff_hunk":"@@ -0,0 +1,38 @@\n+var arity = require('../arity');\n+\n+\n+/**\n+ * Internal curryN function.\n+ *\n+ * @private\n+ * @category Function\n+ * @param {Number} length The arity of the curried function.\n+ * @return {array} An array of arguments received thus far.\n+ * @param {Function} fn The function to curry.\n+ */\n+module.exports = function _curryN(length, recieved, fn) {\n+  return function() {\n+    var combined = [];\n+    var argsIdx = 0;\n+    var left = length;\n+    var combinedIdx = 0;\n+    while (combinedIdx < recieved.length || argsIdx < arguments.length) {\n+      var result;\n+      var rec = recieved[combinedIdx];\n+      var recNotPlaceholder = rec == null || rec['@@functional/placeholder'] !== true;","path":"src/internal/_curryN.js","position":22,"original_position":22,"commit_id":"848d5a2df85c443c44cefd4e7be2f71bb71557c2","original_commit_id":"848d5a2df85c443c44cefd4e7be2f71bb71557c2","user":{"login":"paldepind","id":521604,"avatar_url":"https://avatars.githubusercontent.com/u/521604?v=3","gravatar_id":"","url":"https://api.github.com/users/paldepind","html_url":"https://github.com/paldepind","followers_url":"https://api.github.com/users/paldepind/followers","following_url":"https://api.github.com/users/paldepind/following{/other_user}","gists_url":"https://api.github.com/users/paldepind/gists{/gist_id}","starred_url":"https://api.github.com/users/paldepind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paldepind/subscriptions","organizations_url":"https://api.github.com/users/paldepind/orgs","repos_url":"https://api.github.com/users/paldepind/repos","events_url":"https://api.github.com/users/paldepind/events{/privacy}","received_events_url":"https://api.github.com/users/paldepind/received_events","type":"User","site_admin":false},"body":"It is not my impression that function calls are expensive. At least not in V8. Small functions will in general be optimized better and are subject to inlining. But if this is a concern we should benchmark it. I think the code cleanness advantage would justify it.","created_at":"2015-06-12T16:27:40Z","updated_at":"2015-06-12T16:27:40Z","html_url":"https://github.com/ramda/ramda/pull/1155#discussion_r32331012","pull_request_url":"https://api.github.com/repos/ramda/ramda/pulls/1155","_links":{"self":{"href":"https://api.github.com/repos/ramda/ramda/pulls/comments/32331012"},"html":{"href":"https://github.com/ramda/ramda/pull/1155#discussion_r32331012"},"pull_request":{"href":"https://api.github.com/repos/ramda/ramda/pulls/1155"}}},"pull_request":{"url":"https://api.github.com/repos/ramda/ramda/pulls/1155","id":37014484,"html_url":"https://github.com/ramda/ramda/pull/1155","diff_url":"https://github.com/ramda/ramda/pull/1155.diff","patch_url":"https://github.com/ramda/ramda/pull/1155.patch","issue_url":"https://api.github.com/repos/ramda/ramda/issues/1155","number":1155,"state":"open","locked":false,"title":"Simplify curryN","user":{"login":"paldepind","id":521604,"avatar_url":"https://avatars.githubusercontent.com/u/521604?v=3","gravatar_id":"","url":"https://api.github.com/users/paldepind","html_url":"https://github.com/paldepind","followers_url":"https://api.github.com/users/paldepind/followers","following_url":"https://api.github.com/users/paldepind/following{/other_user}","gists_url":"https://api.github.com/users/paldepind/gists{/gist_id}","starred_url":"https://api.github.com/users/paldepind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paldepind/subscriptions","organizations_url":"https://api.github.com/users/paldepind/orgs","repos_url":"https://api.github.com/users/paldepind/repos","events_url":"https://api.github.com/users/paldepind/events{/privacy}","received_events_url":"https://api.github.com/users/paldepind/received_events","type":"User","site_admin":false},"body":"I've always felt that there was something off with `R.curryN` but my last stab at it resulted in only minor modifications.\r\n\r\nThis PR introduces an internal `_curryN` as a base for the external `curryN`. The internal function has a slightly different signature. The new internal function is half the size of the old `curryN` and completely avoids using `_slice`.\r\n\r\nI've also used `for` loops just to provocate. I think the idea of always using `while` loops is silly. It's like always using `reduce` and forbidding `map`. And the kind of \"consistency\" that is achieved by doing so is just as harmful. Code becomes less expressive and harder to read and understand because you're using a more general construct when a more specific one would capture the desired control flow better. \r\n\r\nHere is the new `_curryN` written with while loops:\r\n\r\n```javascript\r\nmodule.exports = function _curryN(length, recieved, fn) {\r\n  return function() {\r\n    var combined = [];\r\n    var combinedIdx = -1; // What! Minus one? But that's not really where we begin indexing\r\n    var argsIdx = 0;\r\n    var left = length;\r\n    while (++combinedIdx < recieved.length) { // Stuffing increment and condition check into one statement :( :( :(\r\n      var val = recieved[combinedIdx];\r\n      combined[combinedIdx] = val === __ && argsIdx < arguments.length ? arguments[argsIdx++] : val;\r\n      if (combined[combinedIdx] !== __) { --left; }\r\n    }\r\n    while (argsIdx < arguments.length) {\r\n      combined[combinedIdx] = arguments[argsIdx];\r\n      if (combined[combinedIdx] !== __) { --left; }\r\n      combinedIdx++; argsIdx++; // Huh!? For-loops have a well defined location for such increments\r\n    }\r\n    return left <= 0 ? fn.apply(this, combined) : arity(left, _curryN(length, combined, fn));\r\n  };\r\n});\r\n```\r\n\r\nI will change this PR to use `while` loops if requested to do so :)","created_at":"2015-06-05T09:26:16Z","updated_at":"2015-06-12T16:27:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"937eb46e8e6cf9eb2c11ee172d79a79847a05484","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ramda/ramda/pulls/1155/commits","review_comments_url":"https://api.github.com/repos/ramda/ramda/pulls/1155/comments","review_comment_url":"https://api.github.com/repos/ramda/ramda/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ramda/ramda/issues/1155/comments","statuses_url":"https://api.github.com/repos/ramda/ramda/statuses/848d5a2df85c443c44cefd4e7be2f71bb71557c2","head":{"label":"paldepind:simplify-curryn","ref":"simplify-curryn","sha":"848d5a2df85c443c44cefd4e7be2f71bb71557c2","user":{"login":"paldepind","id":521604,"avatar_url":"https://avatars.githubusercontent.com/u/521604?v=3","gravatar_id":"","url":"https://api.github.com/users/paldepind","html_url":"https://github.com/paldepind","followers_url":"https://api.github.com/users/paldepind/followers","following_url":"https://api.github.com/users/paldepind/following{/other_user}","gists_url":"https://api.github.com/users/paldepind/gists{/gist_id}","starred_url":"https://api.github.com/users/paldepind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paldepind/subscriptions","organizations_url":"https://api.github.com/users/paldepind/orgs","repos_url":"https://api.github.com/users/paldepind/repos","events_url":"https://api.github.com/users/paldepind/events{/privacy}","received_events_url":"https://api.github.com/users/paldepind/received_events","type":"User","site_admin":false},"repo":{"id":33441306,"name":"ramda","full_name":"paldepind/ramda","owner":{"login":"paldepind","id":521604,"avatar_url":"https://avatars.githubusercontent.com/u/521604?v=3","gravatar_id":"","url":"https://api.github.com/users/paldepind","html_url":"https://github.com/paldepind","followers_url":"https://api.github.com/users/paldepind/followers","following_url":"https://api.github.com/users/paldepind/following{/other_user}","gists_url":"https://api.github.com/users/paldepind/gists{/gist_id}","starred_url":"https://api.github.com/users/paldepind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paldepind/subscriptions","organizations_url":"https://api.github.com/users/paldepind/orgs","repos_url":"https://api.github.com/users/paldepind/repos","events_url":"https://api.github.com/users/paldepind/events{/privacy}","received_events_url":"https://api.github.com/users/paldepind/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/paldepind/ramda","description":":ram: Practical functional Javascript","fork":true,"url":"https://api.github.com/repos/paldepind/ramda","forks_url":"https://api.github.com/repos/paldepind/ramda/forks","keys_url":"https://api.github.com/repos/paldepind/ramda/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paldepind/ramda/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paldepind/ramda/teams","hooks_url":"https://api.github.com/repos/paldepind/ramda/hooks","issue_events_url":"https://api.github.com/repos/paldepind/ramda/issues/events{/number}","events_url":"https://api.github.com/repos/paldepind/ramda/events","assignees_url":"https://api.github.com/repos/paldepind/ramda/assignees{/user}","branches_url":"https://api.github.com/repos/paldepind/ramda/branches{/branch}","tags_url":"https://api.github.com/repos/paldepind/ramda/tags","blobs_url":"https://api.github.com/repos/paldepind/ramda/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paldepind/ramda/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paldepind/ramda/git/refs{/sha}","trees_url":"https://api.github.com/repos/paldepind/ramda/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paldepind/ramda/statuses/{sha}","languages_url":"https://api.github.com/repos/paldepind/ramda/languages","stargazers_url":"https://api.github.com/repos/paldepind/ramda/stargazers","contributors_url":"https://api.github.com/repos/paldepind/ramda/contributors","subscribers_url":"https://api.github.com/repos/paldepind/ramda/subscribers","subscription_url":"https://api.github.com/repos/paldepind/ramda/subscription","commits_url":"https://api.github.com/repos/paldepind/ramda/commits{/sha}","git_commits_url":"https://api.github.com/repos/paldepind/ramda/git/commits{/sha}","comments_url":"https://api.github.com/repos/paldepind/ramda/comments{/number}","issue_comment_url":"https://api.github.com/repos/paldepind/ramda/issues/comments{/number}","contents_url":"https://api.github.com/repos/paldepind/ramda/contents/{+path}","compare_url":"https://api.github.com/repos/paldepind/ramda/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paldepind/ramda/merges","archive_url":"https://api.github.com/repos/paldepind/ramda/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paldepind/ramda/downloads","issues_url":"https://api.github.com/repos/paldepind/ramda/issues{/number}","pulls_url":"https://api.github.com/repos/paldepind/ramda/pulls{/number}","milestones_url":"https://api.github.com/repos/paldepind/ramda/milestones{/number}","notifications_url":"https://api.github.com/repos/paldepind/ramda/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paldepind/ramda/labels{/name}","releases_url":"https://api.github.com/repos/paldepind/ramda/releases{/id}","created_at":"2015-04-05T13:15:09Z","updated_at":"2015-04-14T11:59:17Z","pushed_at":"2015-06-12T08:13:44Z","git_url":"git://github.com/paldepind/ramda.git","ssh_url":"git@github.com:paldepind/ramda.git","clone_url":"https://github.com/paldepind/ramda.git","svn_url":"https://github.com/paldepind/ramda","homepage":"http://ramdajs.com","size":4726,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ramda:master","ref":"master","sha":"a2fc3132d24188d5b0cbe35704efe2b48b00c70b","user":{"login":"ramda","id":5298359,"avatar_url":"https://avatars.githubusercontent.com/u/5298359?v=3","gravatar_id":"","url":"https://api.github.com/users/ramda","html_url":"https://github.com/ramda","followers_url":"https://api.github.com/users/ramda/followers","following_url":"https://api.github.com/users/ramda/following{/other_user}","gists_url":"https://api.github.com/users/ramda/gists{/gist_id}","starred_url":"https://api.github.com/users/ramda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramda/subscriptions","organizations_url":"https://api.github.com/users/ramda/orgs","repos_url":"https://api.github.com/users/ramda/repos","events_url":"https://api.github.com/users/ramda/events{/privacy}","received_events_url":"https://api.github.com/users/ramda/received_events","type":"Organization","site_admin":false},"repo":{"id":10851820,"name":"ramda","full_name":"ramda/ramda","owner":{"login":"ramda","id":5298359,"avatar_url":"https://avatars.githubusercontent.com/u/5298359?v=3","gravatar_id":"","url":"https://api.github.com/users/ramda","html_url":"https://github.com/ramda","followers_url":"https://api.github.com/users/ramda/followers","following_url":"https://api.github.com/users/ramda/following{/other_user}","gists_url":"https://api.github.com/users/ramda/gists{/gist_id}","starred_url":"https://api.github.com/users/ramda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramda/subscriptions","organizations_url":"https://api.github.com/users/ramda/orgs","repos_url":"https://api.github.com/users/ramda/repos","events_url":"https://api.github.com/users/ramda/events{/privacy}","received_events_url":"https://api.github.com/users/ramda/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ramda/ramda","description":":ram: Practical functional Javascript","fork":false,"url":"https://api.github.com/repos/ramda/ramda","forks_url":"https://api.github.com/repos/ramda/ramda/forks","keys_url":"https://api.github.com/repos/ramda/ramda/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ramda/ramda/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ramda/ramda/teams","hooks_url":"https://api.github.com/repos/ramda/ramda/hooks","issue_events_url":"https://api.github.com/repos/ramda/ramda/issues/events{/number}","events_url":"https://api.github.com/repos/ramda/ramda/events","assignees_url":"https://api.github.com/repos/ramda/ramda/assignees{/user}","branches_url":"https://api.github.com/repos/ramda/ramda/branches{/branch}","tags_url":"https://api.github.com/repos/ramda/ramda/tags","blobs_url":"https://api.github.com/repos/ramda/ramda/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ramda/ramda/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ramda/ramda/git/refs{/sha}","trees_url":"https://api.github.com/repos/ramda/ramda/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ramda/ramda/statuses/{sha}","languages_url":"https://api.github.com/repos/ramda/ramda/languages","stargazers_url":"https://api.github.com/repos/ramda/ramda/stargazers","contributors_url":"https://api.github.com/repos/ramda/ramda/contributors","subscribers_url":"https://api.github.com/repos/ramda/ramda/subscribers","subscription_url":"https://api.github.com/repos/ramda/ramda/subscription","commits_url":"https://api.github.com/repos/ramda/ramda/commits{/sha}","git_commits_url":"https://api.github.com/repos/ramda/ramda/git/commits{/sha}","comments_url":"https://api.github.com/repos/ramda/ramda/comments{/number}","issue_comment_url":"https://api.github.com/repos/ramda/ramda/issues/comments{/number}","contents_url":"https://api.github.com/repos/ramda/ramda/contents/{+path}","compare_url":"https://api.github.com/repos/ramda/ramda/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ramda/ramda/merges","archive_url":"https://api.github.com/repos/ramda/ramda/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ramda/ramda/downloads","issues_url":"https://api.github.com/repos/ramda/ramda/issues{/number}","pulls_url":"https://api.github.com/repos/ramda/ramda/pulls{/number}","milestones_url":"https://api.github.com/repos/ramda/ramda/milestones{/number}","notifications_url":"https://api.github.com/repos/ramda/ramda/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ramda/ramda/labels{/name}","releases_url":"https://api.github.com/repos/ramda/ramda/releases{/id}","created_at":"2013-06-21T20:32:35Z","updated_at":"2015-06-12T16:22:39Z","pushed_at":"2015-06-12T08:48:33Z","git_url":"git://github.com/ramda/ramda.git","ssh_url":"git@github.com:ramda/ramda.git","clone_url":"https://github.com/ramda/ramda.git","svn_url":"https://github.com/ramda/ramda","homepage":"http://ramdajs.com","size":10218,"stargazers_count":2205,"watchers_count":2205,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":169,"mirror_url":null,"open_issues_count":51,"forks":169,"open_issues":51,"watchers":2205,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ramda/ramda/pulls/1155"},"html":{"href":"https://github.com/ramda/ramda/pull/1155"},"issue":{"href":"https://api.github.com/repos/ramda/ramda/issues/1155"},"comments":{"href":"https://api.github.com/repos/ramda/ramda/issues/1155/comments"},"review_comments":{"href":"https://api.github.com/repos/ramda/ramda/pulls/1155/comments"},"review_comment":{"href":"https://api.github.com/repos/ramda/ramda/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ramda/ramda/pulls/1155/commits"},"statuses":{"href":"https://api.github.com/repos/ramda/ramda/statuses/848d5a2df85c443c44cefd4e7be2f71bb71557c2"}}}}