{"action":"closed","issue":{"url":"https://api.github.com/repos/da2k/curso-reactjs-ninja/issues/44","repository_url":"https://api.github.com/repos/da2k/curso-reactjs-ninja","labels_url":"https://api.github.com/repos/da2k/curso-reactjs-ninja/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/da2k/curso-reactjs-ninja/issues/44/comments","events_url":"https://api.github.com/repos/da2k/curso-reactjs-ninja/issues/44/events","html_url":"https://github.com/da2k/curso-reactjs-ninja/issues/44","id":249473731,"number":44,"title":"M2#A13 - Map recursivo","user":{"login":"willianribeiro","id":3102551,"avatar_url":"https://avatars1.githubusercontent.com/u/3102551?v=4","gravatar_id":"","url":"https://api.github.com/users/willianribeiro","html_url":"https://github.com/willianribeiro","followers_url":"https://api.github.com/users/willianribeiro/followers","following_url":"https://api.github.com/users/willianribeiro/following{/other_user}","gists_url":"https://api.github.com/users/willianribeiro/gists{/gist_id}","starred_url":"https://api.github.com/users/willianribeiro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willianribeiro/subscriptions","organizations_url":"https://api.github.com/users/willianribeiro/orgs","repos_url":"https://api.github.com/users/willianribeiro/repos","events_url":"https://api.github.com/users/willianribeiro/events{/privacy}","received_events_url":"https://api.github.com/users/willianribeiro/received_events","type":"User","site_admin":false},"labels":[{"id":384373221,"url":"https://api.github.com/repos/da2k/curso-reactjs-ninja/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-08-10T20:55:49Z","updated_at":"2017-08-11T17:27:09Z","closed_at":"2017-08-11T17:27:09Z","body":"Faaaala Daciuk, tudo certin?!\r\n\r\nEm um ponto da aula 13 temos este código [1]. Neste momento você comenta que para termos uma programação 100% funcional precisamos remover o if. Então chegamos a este outro código [2].\r\n\r\nA minha pergunta é: por que em programação funcional não poderiamos ter o if? O ternário faz quase a mesma coisa (ao meu ver), mas ele é permitido e o if não, por quê isso ? .-.\r\n\r\nMe ajuda a esclarecer? Abraço!\r\n\r\n[1]\r\n```\r\n'use strict'\r\n\r\nconst map = (arr = [], func = (item) => item) => {\r\n    const counter = 0;\r\n\r\n    return (function mapInternal (arrInternal, counter) {\r\n        if (arrInternal.length === 0)\r\n            return [];\r\n\r\n        const [head, ...tail] = arrInternal;\r\n        return [\r\n            func(head, counter, arr), \r\n            ...mapInternal(tail, counter + 1)\r\n        ];\r\n    })(arr, counter);\r\n}\r\n\r\nexport default map;\r\n```\r\n\r\n[2]\r\n```\r\n'use strict'\r\n\r\nconst map = (arr = [], func = (item) => item) => {\r\n    const counter = 0;\r\n\r\n    return (function mapInternal (arrInternal, counter) {\r\n        const [head, ...tail] = arrInternal;\r\n        \r\n        return arrInternal.length === 0 ? [] : [\r\n            func(head, counter, arr), \r\n            ...mapInternal(tail, counter + 1)\r\n        ];\r\n    })(arr, counter);\r\n}\r\n\r\nexport default map;\r\n```\r\n\r\n<!-- Não apague daqui pra baixo! -->\r\n@fdaciuk\r\n"}}
{"actor":{"display_login":"fdaciuk"}}