{"action":"created","comment":{"url":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/comments/49862761","id":49862761,"diff_hunk":"@@ -24,19 +24,21 @@ var Jacky = {\n function isAReversedSuite(number) {\n     return isASuite(number, true)\n }\n-        \n+\n function isASuite(number, reverse) {\n     var asArray = number.toString().split('');\n     if (reverse) {\n         asArray = asArray.reverse()\n     }\n-    for(var i = 0; i < asArray.length -1; i++) {\n-        if( parseInt(asArray[i]) !=  parseInt(asArray[i +1]) - 1) {\n-            return false\n-        }\n-    }\n-   \n-    return true\n+    var result = asArray.map(\n+      function(item){\n+        return parseInt(item)\n+    }).reduce(\n+      function(acc, value) {\n+        if(!acc) return false;\n+        return (acc + 1 == value) ? value : false\n+      })\n+    return !!result","path":"js/Jacky.js","position":26,"original_position":26,"commit_id":"b000bc744fe6ca84cbb3a481d6a3fe119fa91b5e","original_commit_id":"b000bc744fe6ca84cbb3a481d6a3fe119fa91b5e","user":{"login":"laem","id":1177762,"avatar_url":"https://avatars.githubusercontent.com/u/1177762?v=3","gravatar_id":"","url":"https://api.github.com/users/laem","html_url":"https://github.com/laem","followers_url":"https://api.github.com/users/laem/followers","following_url":"https://api.github.com/users/laem/following{/other_user}","gists_url":"https://api.github.com/users/laem/gists{/gist_id}","starred_url":"https://api.github.com/users/laem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laem/subscriptions","organizations_url":"https://api.github.com/users/laem/orgs","repos_url":"https://api.github.com/users/laem/repos","events_url":"https://api.github.com/users/laem/events{/privacy}","received_events_url":"https://api.github.com/users/laem/received_events","type":"User","site_admin":false},"body":"Une idée d'implémentation en Clojure :\r\n\r\n```clj\r\n(->> sequence\r\n       (map - (rest sequence))\r\n       distinct\r\n       (= [1])\r\n       )\r\n```\r\nY a sûrement encore plus clair dans d'autres langages...","created_at":"2016-01-15T15:09:02Z","updated_at":"2016-01-15T15:09:02Z","html_url":"https://github.com/sgmap/coding-dojo--1/pull/1#discussion_r49862761","pull_request_url":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/comments/49862761"},"html":{"href":"https://github.com/sgmap/coding-dojo--1/pull/1#discussion_r49862761"},"pull_request":{"href":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/1","id":56073839,"html_url":"https://github.com/sgmap/coding-dojo--1/pull/1","diff_url":"https://github.com/sgmap/coding-dojo--1/pull/1.diff","patch_url":"https://github.com/sgmap/coding-dojo--1/pull/1.patch","issue_url":"https://api.github.com/repos/sgmap/coding-dojo--1/issues/1","number":1,"state":"open","locked":false,"title":"use reduce instead of a loop (not necessary better)","user":{"login":"ThibautGery","id":5861569,"avatar_url":"https://avatars.githubusercontent.com/u/5861569?v=3","gravatar_id":"","url":"https://api.github.com/users/ThibautGery","html_url":"https://github.com/ThibautGery","followers_url":"https://api.github.com/users/ThibautGery/followers","following_url":"https://api.github.com/users/ThibautGery/following{/other_user}","gists_url":"https://api.github.com/users/ThibautGery/gists{/gist_id}","starred_url":"https://api.github.com/users/ThibautGery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThibautGery/subscriptions","organizations_url":"https://api.github.com/users/ThibautGery/orgs","repos_url":"https://api.github.com/users/ThibautGery/repos","events_url":"https://api.github.com/users/ThibautGery/events{/privacy}","received_events_url":"https://api.github.com/users/ThibautGery/received_events","type":"User","site_admin":false},"body":"J'ai simplement utilisé la fonction reduce au lieu d'une boucle pour l'approche fonctionnel, ça change rien de fondamentale. C'était plus pour l'exercice qu'autre chose.\r\n\r\nSinon j'ai découvert que `[1, 2].map(parseInt)` ne fonctionne pas car `map` a plusieurs arguments tout comme `parseInt` [link](http://stackoverflow.com/questions/262427/javascript-arraymap-and-parseint)\r\n\r\nJ'utilse [reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce) qui a donc un accumulateur qui contient false si ce n'est pas une suite ou alors contient la valeur du champ précédent.\r\nEnfin le `return !!result` permet de forcer la dernière valeur à true\r\n\r\nEt je pense pas que ça soit plus clair que votre version mais c'était marrant à faire","created_at":"2016-01-14T18:25:09Z","updated_at":"2016-01-15T15:09:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d7faad7c68351342298679e39fe15fd0ae17c7a1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/1/commits","review_comments_url":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/1/comments","review_comment_url":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sgmap/coding-dojo--1/issues/1/comments","statuses_url":"https://api.github.com/repos/sgmap/coding-dojo--1/statuses/b000bc744fe6ca84cbb3a481d6a3fe119fa91b5e","head":{"label":"ThibautGery:master","ref":"master","sha":"b000bc744fe6ca84cbb3a481d6a3fe119fa91b5e","user":{"login":"ThibautGery","id":5861569,"avatar_url":"https://avatars.githubusercontent.com/u/5861569?v=3","gravatar_id":"","url":"https://api.github.com/users/ThibautGery","html_url":"https://github.com/ThibautGery","followers_url":"https://api.github.com/users/ThibautGery/followers","following_url":"https://api.github.com/users/ThibautGery/following{/other_user}","gists_url":"https://api.github.com/users/ThibautGery/gists{/gist_id}","starred_url":"https://api.github.com/users/ThibautGery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThibautGery/subscriptions","organizations_url":"https://api.github.com/users/ThibautGery/orgs","repos_url":"https://api.github.com/users/ThibautGery/repos","events_url":"https://api.github.com/users/ThibautGery/events{/privacy}","received_events_url":"https://api.github.com/users/ThibautGery/received_events","type":"User","site_admin":false},"repo":{"id":49664897,"name":"coding-dojo--1","full_name":"ThibautGery/coding-dojo--1","owner":{"login":"ThibautGery","id":5861569,"avatar_url":"https://avatars.githubusercontent.com/u/5861569?v=3","gravatar_id":"","url":"https://api.github.com/users/ThibautGery","html_url":"https://github.com/ThibautGery","followers_url":"https://api.github.com/users/ThibautGery/followers","following_url":"https://api.github.com/users/ThibautGery/following{/other_user}","gists_url":"https://api.github.com/users/ThibautGery/gists{/gist_id}","starred_url":"https://api.github.com/users/ThibautGery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThibautGery/subscriptions","organizations_url":"https://api.github.com/users/ThibautGery/orgs","repos_url":"https://api.github.com/users/ThibautGery/repos","events_url":"https://api.github.com/users/ThibautGery/events{/privacy}","received_events_url":"https://api.github.com/users/ThibautGery/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ThibautGery/coding-dojo--1","description":"Coding-dojo #1 du 14/01/2016 - \"JS les bases\"","fork":true,"url":"https://api.github.com/repos/ThibautGery/coding-dojo--1","forks_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/forks","keys_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/teams","hooks_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/hooks","issue_events_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/issues/events{/number}","events_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/events","assignees_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/assignees{/user}","branches_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/branches{/branch}","tags_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/tags","blobs_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/git/refs{/sha}","trees_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/statuses/{sha}","languages_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/languages","stargazers_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/stargazers","contributors_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/contributors","subscribers_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/subscribers","subscription_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/subscription","commits_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/commits{/sha}","git_commits_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/git/commits{/sha}","comments_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/comments{/number}","issue_comment_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/issues/comments{/number}","contents_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/contents/{+path}","compare_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/merges","archive_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/downloads","issues_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/issues{/number}","pulls_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/pulls{/number}","milestones_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/milestones{/number}","notifications_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/labels{/name}","releases_url":"https://api.github.com/repos/ThibautGery/coding-dojo--1/releases{/id}","created_at":"2016-01-14T17:59:04Z","updated_at":"2016-01-14T17:59:05Z","pushed_at":"2016-01-14T18:18:25Z","git_url":"git://github.com/ThibautGery/coding-dojo--1.git","ssh_url":"git@github.com:ThibautGery/coding-dojo--1.git","clone_url":"https://github.com/ThibautGery/coding-dojo--1.git","svn_url":"https://github.com/ThibautGery/coding-dojo--1","homepage":null,"size":3,"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":"sgmap:master","ref":"master","sha":"840a25e768ca24da73bf1104e8979ec25565c1e5","user":{"login":"sgmap","id":7874148,"avatar_url":"https://avatars.githubusercontent.com/u/7874148?v=3","gravatar_id":"","url":"https://api.github.com/users/sgmap","html_url":"https://github.com/sgmap","followers_url":"https://api.github.com/users/sgmap/followers","following_url":"https://api.github.com/users/sgmap/following{/other_user}","gists_url":"https://api.github.com/users/sgmap/gists{/gist_id}","starred_url":"https://api.github.com/users/sgmap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgmap/subscriptions","organizations_url":"https://api.github.com/users/sgmap/orgs","repos_url":"https://api.github.com/users/sgmap/repos","events_url":"https://api.github.com/users/sgmap/events{/privacy}","received_events_url":"https://api.github.com/users/sgmap/received_events","type":"Organization","site_admin":false},"repo":{"id":49653491,"name":"coding-dojo--1","full_name":"sgmap/coding-dojo--1","owner":{"login":"sgmap","id":7874148,"avatar_url":"https://avatars.githubusercontent.com/u/7874148?v=3","gravatar_id":"","url":"https://api.github.com/users/sgmap","html_url":"https://github.com/sgmap","followers_url":"https://api.github.com/users/sgmap/followers","following_url":"https://api.github.com/users/sgmap/following{/other_user}","gists_url":"https://api.github.com/users/sgmap/gists{/gist_id}","starred_url":"https://api.github.com/users/sgmap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgmap/subscriptions","organizations_url":"https://api.github.com/users/sgmap/orgs","repos_url":"https://api.github.com/users/sgmap/repos","events_url":"https://api.github.com/users/sgmap/events{/privacy}","received_events_url":"https://api.github.com/users/sgmap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sgmap/coding-dojo--1","description":"Coding-dojo #1 du 14/01/2016 - \"JS les bases\"","fork":false,"url":"https://api.github.com/repos/sgmap/coding-dojo--1","forks_url":"https://api.github.com/repos/sgmap/coding-dojo--1/forks","keys_url":"https://api.github.com/repos/sgmap/coding-dojo--1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sgmap/coding-dojo--1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sgmap/coding-dojo--1/teams","hooks_url":"https://api.github.com/repos/sgmap/coding-dojo--1/hooks","issue_events_url":"https://api.github.com/repos/sgmap/coding-dojo--1/issues/events{/number}","events_url":"https://api.github.com/repos/sgmap/coding-dojo--1/events","assignees_url":"https://api.github.com/repos/sgmap/coding-dojo--1/assignees{/user}","branches_url":"https://api.github.com/repos/sgmap/coding-dojo--1/branches{/branch}","tags_url":"https://api.github.com/repos/sgmap/coding-dojo--1/tags","blobs_url":"https://api.github.com/repos/sgmap/coding-dojo--1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sgmap/coding-dojo--1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sgmap/coding-dojo--1/git/refs{/sha}","trees_url":"https://api.github.com/repos/sgmap/coding-dojo--1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sgmap/coding-dojo--1/statuses/{sha}","languages_url":"https://api.github.com/repos/sgmap/coding-dojo--1/languages","stargazers_url":"https://api.github.com/repos/sgmap/coding-dojo--1/stargazers","contributors_url":"https://api.github.com/repos/sgmap/coding-dojo--1/contributors","subscribers_url":"https://api.github.com/repos/sgmap/coding-dojo--1/subscribers","subscription_url":"https://api.github.com/repos/sgmap/coding-dojo--1/subscription","commits_url":"https://api.github.com/repos/sgmap/coding-dojo--1/commits{/sha}","git_commits_url":"https://api.github.com/repos/sgmap/coding-dojo--1/git/commits{/sha}","comments_url":"https://api.github.com/repos/sgmap/coding-dojo--1/comments{/number}","issue_comment_url":"https://api.github.com/repos/sgmap/coding-dojo--1/issues/comments{/number}","contents_url":"https://api.github.com/repos/sgmap/coding-dojo--1/contents/{+path}","compare_url":"https://api.github.com/repos/sgmap/coding-dojo--1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sgmap/coding-dojo--1/merges","archive_url":"https://api.github.com/repos/sgmap/coding-dojo--1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sgmap/coding-dojo--1/downloads","issues_url":"https://api.github.com/repos/sgmap/coding-dojo--1/issues{/number}","pulls_url":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls{/number}","milestones_url":"https://api.github.com/repos/sgmap/coding-dojo--1/milestones{/number}","notifications_url":"https://api.github.com/repos/sgmap/coding-dojo--1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sgmap/coding-dojo--1/labels{/name}","releases_url":"https://api.github.com/repos/sgmap/coding-dojo--1/releases{/id}","created_at":"2016-01-14T14:51:01Z","updated_at":"2016-01-14T15:29:23Z","pushed_at":"2016-01-14T18:25:09Z","git_url":"git://github.com/sgmap/coding-dojo--1.git","ssh_url":"git@github.com:sgmap/coding-dojo--1.git","clone_url":"https://github.com/sgmap/coding-dojo--1.git","svn_url":"https://github.com/sgmap/coding-dojo--1","homepage":null,"size":3,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/1"},"html":{"href":"https://github.com/sgmap/coding-dojo--1/pull/1"},"issue":{"href":"https://api.github.com/repos/sgmap/coding-dojo--1/issues/1"},"comments":{"href":"https://api.github.com/repos/sgmap/coding-dojo--1/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sgmap/coding-dojo--1/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/sgmap/coding-dojo--1/statuses/b000bc744fe6ca84cbb3a481d6a3fe119fa91b5e"}}}}