<commit_before>---
layout: post
title:  "Currying (Functional programming II)"
date:   2016-02-05 14:00:00
author: <NAME>
categories: functional 
tags:	functional 
cover:  "assets/functional_programming_part_1.jpg"
---

With this concept I still have problems. I can see how it works, I can see some uses, but I'm still learning why is so important in other languages as Haskell. Still I want to share with you my advancements because it's a very interesting stuff.

So... currying. What's that? `Currying` is a way of constructing functions that allows partial application of a function’s arguments. So you can pass all the arguments to a function and get the result, or only pass a subset of those arguments and get the function that is waiting the rest of the arguments.

Yeah, it's confusing, I know. Let's do an example so we can understand first the concept.
 
 
        function starTrekCharacter(name, planet, profession) {
            return "I'm " + name + " from the planet " + planet + " and I am a " + profession;
        }
    
        console.log(starTrekCharacter("Spock", "Vulcano", "science officer"))
        // returns I'm Spock from the planet Vulcano and I am a science officer

Easy enough. Now we are going to "disintrigrate" this function in multiple functions

    function starTrekCharacter(name) {
        return function(planet) {
            return function(profession) {
                return "I'm " + name + " from the planet " + planet + " and I am a " + profession;
            }
        }<commit_msg>Functional programming II: Curry functions<commit_after>---
layout: post
title:  "Currying (Functional programming II)"
date:   2016-02-05 14:00:00
author: <NAME>
categories: functional 
tags:	functional 
cover:  "assets/functional_programming_part_2.jpg"
---

With this concept I still have problems. I can see how it works, I can see some uses, but I'm still learning why is so important in other languages as Haskell. Still I want to share with you my advancements because it's a very interesting stuff.

So... currying. What's that? `Currying` is a way of constructing functions that allows partial application of a function’s arguments. So you can pass all the arguments to a function and get the result, or only pass a subset of those arguments and get the function that is waiting the rest of the arguments.

Yeah, it's confusing, I know. Let's do an example so we can understand first the concept.
 
 
        function starTrekCharacter(name, planet, profession) {
            return "I'm " + name + " from the planet " + planet + " and I am a " + profession;
        }
    
        console.log(starTrekCharacter("Spock", "Vulcano", "science officer"))
        // returns I'm Spock from the planet Vulcano and I am a science officer

Easy enough. Now we are going to "disintrigrate" this function in multiple functions

    function starTrekCharacter(name) {
        return function(planet) {
            return function(profession) {
                return "I'm " + name + " from the planet " + planet + " and I am a " + profession;
            }
        }
{'fraction_non_alphanumeric': 0.07578200580457917, 'fraction_numerical': 0.009674298613350531, 'mean_word_length': 3.108609271523179, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2978745', 'n_tokens_mistral': 866, 'n_tokens_neox': 799, 'n_words': 400}