{"action":"created","issue":{"url":"https://api.github.com/repos/narimiran/itertools/issues/3","repository_url":"https://api.github.com/repos/narimiran/itertools","labels_url":"https://api.github.com/repos/narimiran/itertools/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/narimiran/itertools/issues/3/comments","events_url":"https://api.github.com/repos/narimiran/itertools/issues/3/events","html_url":"https://github.com/narimiran/itertools/issues/3","id":365157030,"node_id":"MDU6SXNzdWUzNjUxNTcwMzA=","number":3,"title":"Possible nim version of permutations()","user":{"login":"zetashift","id":1857826,"node_id":"MDQ6VXNlcjE4NTc4MjY=","avatar_url":"https://avatars1.githubusercontent.com/u/1857826?v=4","gravatar_id":"","url":"https://api.github.com/users/zetashift","html_url":"https://github.com/zetashift","followers_url":"https://api.github.com/users/zetashift/followers","following_url":"https://api.github.com/users/zetashift/following{/other_user}","gists_url":"https://api.github.com/users/zetashift/gists{/gist_id}","starred_url":"https://api.github.com/users/zetashift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zetashift/subscriptions","organizations_url":"https://api.github.com/users/zetashift/orgs","repos_url":"https://api.github.com/users/zetashift/repos","events_url":"https://api.github.com/users/zetashift/events{/privacy}","received_events_url":"https://api.github.com/users/zetashift/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-09-29T18:45:31Z","updated_at":"2018-10-04T10:20:35Z","closed_at":"2018-10-04T10:20:35Z","author_association":"NONE","body":"Heya, I've been working through rosalind.info exercises and a few are easily solvable by a default permutations function. I failed to solve it with nim because I'm not smart enough and ended up with using Scala's permutations function.\r\nAfter I solved it I went through the solutions and everybody used the permutations function from python itertools. I was wondering if this lib will support such a thing/best way to go at it would be.\r\n\r\nFor one of the exercises I did make a recursive solution thanks to rosettacode:\r\n```nim\r\nproc permutations(ls: openArray[int], emit: proc(emit: openArray[int])) =\r\n    var s = @ls\r\n    if s.len == 0:\r\n        emit(s)\r\n        return\r\n    \r\n    var rc: proc(np: int)\r\n    rc = proc(np: int) =\r\n        if np == 1:\r\n            emit(s)\r\n            return\r\n        var\r\n            np1 = np-1\r\n            pp = s.len - np1\r\n        rc(np1)\r\n        for i in countdown(pp, 1):\r\n            swap s[i], s[i-1]\r\n            rc(np1)\r\n        let w = s[0]\r\n        s[0..pp-1] = s[1..pp]\r\n        s[pp] = w\r\n    rc(s.len)\r\n```"},"comment":{"url":"https://api.github.com/repos/narimiran/itertools/issues/comments/426964842","html_url":"https://github.com/narimiran/itertools/issues/3#issuecomment-426964842","issue_url":"https://api.github.com/repos/narimiran/itertools/issues/3","id":426964842,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNjk2NDg0Mg==","user":{"login":"narimiran","id":16516130,"node_id":"MDQ6VXNlcjE2NTE2MTMw","avatar_url":"https://avatars2.githubusercontent.com/u/16516130?v=4","gravatar_id":"","url":"https://api.github.com/users/narimiran","html_url":"https://github.com/narimiran","followers_url":"https://api.github.com/users/narimiran/followers","following_url":"https://api.github.com/users/narimiran/following{/other_user}","gists_url":"https://api.github.com/users/narimiran/gists{/gist_id}","starred_url":"https://api.github.com/users/narimiran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/narimiran/subscriptions","organizations_url":"https://api.github.com/users/narimiran/orgs","repos_url":"https://api.github.com/users/narimiran/repos","events_url":"https://api.github.com/users/narimiran/events{/privacy}","received_events_url":"https://api.github.com/users/narimiran/received_events","type":"User","site_admin":false},"created_at":"2018-10-04T10:20:35Z","updated_at":"2018-10-04T10:20:35Z","author_association":"OWNER","body":"Ok, I released a new version which now contains these combinatoric iterators:\r\n\r\n* product\r\n* distinctPermutations\r\n* permutations\r\n* combinations\r\n\r\nI hope this now closes this issue. (If not, please reopen it)"}}
{"actor":{"display_login":"narimiran"}}