What exactly is meant by “partial function” in functional programming?What is a monad?What are metaclasses in Python?What is the difference between @staticmethod and @classmethod?What does the “yield” keyword do?What is the difference between Python's list methods append and extend?What does if __name__ == “__main__”: do?Using global variables in a functionHow to make a chain of function decorators?What is (functional) reactive programming?“Least Astonishment” and the Mutable Default Argument

Can Microsoft employees see my data in Azure?

What exactly is meant by "partial function" in functional programming?

Use GPLv3 library in a closed system (no software distribution)

Are Star Trek races uniform?

Who discovered the covering homomorphism between SU(2) and SO(3)?

What is gerrymandering called if it's not the result of redrawing districts?

How to cut a perfect shape out of 4cm oak?

Have the US and Russia (or USSR before it) co-vetoed a UN resolution before today?

What is the white square near the viewfinder of the Fujica GW690?

When is "了" pronounced "le" and when is it pronounced "liao"?

Why are Krueger flaps called flaps and not slats?

Moving through the space of an invisible enemy creature in combat

Reading GeoPackage with large features is very slow

I run daily 5kms but I cant seem to improve stamina when playing soccer

Linux Commands in Python

Does any politician - honestly - want a No Deal Brexit?

When was the famous "sudo warning" introduced? Under what background? By whom?

Oko, Thief of Crown's +1 vs. Deputy of Detention

Does code obfuscation give any measurable security benefit?

Sitecore Powershell skip items in System Folder

Nobel prize in literature 2018 - what is "encyclopedic passion"?

Interrupt child processes from bash script on Ctrl+C

Why is 10.1.255.255 an invalid broadcast address?

Meaning of “Bulldog drooled courses through his jowls”



What exactly is meant by “partial function” in functional programming?


What is a monad?What are metaclasses in Python?What is the difference between @staticmethod and @classmethod?What does the “yield” keyword do?What is the difference between Python's list methods append and extend?What does if __name__ == “__main__”: do?Using global variables in a functionHow to make a chain of function decorators?What is (functional) reactive programming?“Least Astonishment” and the Mutable Default Argument






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









11

















According to my understanding, partial functions are functions that we get by passing fewer parameters to a function than expected. For example, in Python:



def add(x,y):
return x+y

>> new_function = add(1)
>> new_function(2)
>> 3


In the snippet above, new_function is a partial function. However, according to the Haskell Wiki, the definition of partial function is




A partial function is a function that is not defined for all possible arguments of the specified type.




so, my question is: what exactly is meant by "partial function"?










share|improve this question























  • 13





    You are confusing a partially applied function with a partial function.

    – Willem Van Onsem
    11 hours ago






  • 7





    Python's partial performs partial application, whereas Haskell does that automatically. The wiki entry refers to partial functions, which is a term from mathematics.

    – L3viathan
    11 hours ago











  • yes. Thanks for info @WillemVanOnsem

    – Saurabh kukade
    11 hours ago












  • yes. Thanks for info @L3viathan

    – Saurabh kukade
    11 hours ago






  • 2





    Strictly speaking, Haskell doesn't do partial function application. Every function takes one argument, and function application applies a function to a single argument. Currying simulates what you would think of as partial application in another language by simulating multiple-argument functions in the first place. Something like add 3 5 isn't a single function application. This first applies add to 3 to get a new function, which is then applied to 5.

    – chepner
    10 hours ago


















11

















According to my understanding, partial functions are functions that we get by passing fewer parameters to a function than expected. For example, in Python:



def add(x,y):
return x+y

>> new_function = add(1)
>> new_function(2)
>> 3


In the snippet above, new_function is a partial function. However, according to the Haskell Wiki, the definition of partial function is




A partial function is a function that is not defined for all possible arguments of the specified type.




so, my question is: what exactly is meant by "partial function"?










share|improve this question























  • 13





    You are confusing a partially applied function with a partial function.

    – Willem Van Onsem
    11 hours ago






  • 7





    Python's partial performs partial application, whereas Haskell does that automatically. The wiki entry refers to partial functions, which is a term from mathematics.

    – L3viathan
    11 hours ago











  • yes. Thanks for info @WillemVanOnsem

    – Saurabh kukade
    11 hours ago












  • yes. Thanks for info @L3viathan

    – Saurabh kukade
    11 hours ago






  • 2





    Strictly speaking, Haskell doesn't do partial function application. Every function takes one argument, and function application applies a function to a single argument. Currying simulates what you would think of as partial application in another language by simulating multiple-argument functions in the first place. Something like add 3 5 isn't a single function application. This first applies add to 3 to get a new function, which is then applied to 5.

    – chepner
    10 hours ago














11












11








11


1






According to my understanding, partial functions are functions that we get by passing fewer parameters to a function than expected. For example, in Python:



def add(x,y):
return x+y

>> new_function = add(1)
>> new_function(2)
>> 3


In the snippet above, new_function is a partial function. However, according to the Haskell Wiki, the definition of partial function is




A partial function is a function that is not defined for all possible arguments of the specified type.




so, my question is: what exactly is meant by "partial function"?










share|improve this question

















According to my understanding, partial functions are functions that we get by passing fewer parameters to a function than expected. For example, in Python:



def add(x,y):
return x+y

>> new_function = add(1)
>> new_function(2)
>> 3


In the snippet above, new_function is a partial function. However, according to the Haskell Wiki, the definition of partial function is




A partial function is a function that is not defined for all possible arguments of the specified type.




so, my question is: what exactly is meant by "partial function"?







python haskell functional-programming partial-application partial-functions






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








edited 13 mins ago









Rodrigo de Azevedo

8186 silver badges17 bronze badges




8186 silver badges17 bronze badges










asked 11 hours ago









Saurabh kukadeSaurabh kukade

2131 silver badge11 bronze badges




2131 silver badge11 bronze badges










  • 13





    You are confusing a partially applied function with a partial function.

    – Willem Van Onsem
    11 hours ago






  • 7





    Python's partial performs partial application, whereas Haskell does that automatically. The wiki entry refers to partial functions, which is a term from mathematics.

    – L3viathan
    11 hours ago











  • yes. Thanks for info @WillemVanOnsem

    – Saurabh kukade
    11 hours ago












  • yes. Thanks for info @L3viathan

    – Saurabh kukade
    11 hours ago






  • 2





    Strictly speaking, Haskell doesn't do partial function application. Every function takes one argument, and function application applies a function to a single argument. Currying simulates what you would think of as partial application in another language by simulating multiple-argument functions in the first place. Something like add 3 5 isn't a single function application. This first applies add to 3 to get a new function, which is then applied to 5.

    – chepner
    10 hours ago













  • 13





    You are confusing a partially applied function with a partial function.

    – Willem Van Onsem
    11 hours ago






  • 7





    Python's partial performs partial application, whereas Haskell does that automatically. The wiki entry refers to partial functions, which is a term from mathematics.

    – L3viathan
    11 hours ago











  • yes. Thanks for info @WillemVanOnsem

    – Saurabh kukade
    11 hours ago












  • yes. Thanks for info @L3viathan

    – Saurabh kukade
    11 hours ago






  • 2





    Strictly speaking, Haskell doesn't do partial function application. Every function takes one argument, and function application applies a function to a single argument. Currying simulates what you would think of as partial application in another language by simulating multiple-argument functions in the first place. Something like add 3 5 isn't a single function application. This first applies add to 3 to get a new function, which is then applied to 5.

    – chepner
    10 hours ago








13




13





You are confusing a partially applied function with a partial function.

– Willem Van Onsem
11 hours ago





You are confusing a partially applied function with a partial function.

– Willem Van Onsem
11 hours ago




7




7





Python's partial performs partial application, whereas Haskell does that automatically. The wiki entry refers to partial functions, which is a term from mathematics.

– L3viathan
11 hours ago





Python's partial performs partial application, whereas Haskell does that automatically. The wiki entry refers to partial functions, which is a term from mathematics.

– L3viathan
11 hours ago













yes. Thanks for info @WillemVanOnsem

– Saurabh kukade
11 hours ago






yes. Thanks for info @WillemVanOnsem

– Saurabh kukade
11 hours ago














yes. Thanks for info @L3viathan

– Saurabh kukade
11 hours ago





yes. Thanks for info @L3viathan

– Saurabh kukade
11 hours ago




2




2





Strictly speaking, Haskell doesn't do partial function application. Every function takes one argument, and function application applies a function to a single argument. Currying simulates what you would think of as partial application in another language by simulating multiple-argument functions in the first place. Something like add 3 5 isn't a single function application. This first applies add to 3 to get a new function, which is then applied to 5.

– chepner
10 hours ago






Strictly speaking, Haskell doesn't do partial function application. Every function takes one argument, and function application applies a function to a single argument. Currying simulates what you would think of as partial application in another language by simulating multiple-argument functions in the first place. Something like add 3 5 isn't a single function application. This first applies add to 3 to get a new function, which is then applied to 5.

– chepner
10 hours ago













3 Answers
3






active

oldest

votes


















16


















You are here confusing two concepts. A partially applied function [haskell-wiki] with a partial function [haskell-wiki].



A partially applied function is:




Partial application in Haskell involves passing less than the full number of arguments to a function that takes multiple arguments.




whereas a partial function indeed is a non-total function:




A partial function is a function that is not defined for all possible arguments of the specified type.







share|improve this answer

































    9


















    A partial function (both in the context of functional programming and mathematics) is exactly what the wiki says: a function not defined for all of its possible arguments. In the context of programming, we usually interpret "not defined" as one of several things, including undefined behaviour, exceptions or non-termination.



    An example of a partial function would be integer division, which is not defined if the divisor is 0 (in Haskell it will throw an error).




    in above snippet new_function is partial function.




    That code would simply cause an error in Python, but if it worked as you intended, it would be a total (meaning not partial) function.



    As commentors already pointed out, you're most likely thinking of the fact that it'd be a partially applied function.






    share|improve this answer

































      3


















      The answers explain all, I will just add one example in each language:



      def add(x,y):
      return x+y

      f = add(1)
      print(f(3))

      f = add(1)
      TypeError: add() missing 1 required positional argument: 'y'


      this is neither a partial function nor a curried function, is a function that you didn't gave all its arguments.



      a curried function like in Haskell should be:



      partialAdd= lambda x: lambda y: x + y

      plusOne = partialAdd(1)
      print(plusOne(3))

      4


      and in haskell:



      plus :: Int -> Int -> Int
      plus x y = x + y

      plusOne = plus 1

      plusOne 4

      5


      A partial function in python:



      def first(ls):
      return ls[0]

      print(first([2,4,5]))
      print(first([]))



      output




      2

      print(first([]))
      File "main.py", line 2, in first
      return ls[0]
      IndexError: list index out of range


      And in Haskell, as your link showed up:



      head [1,2,3]
      3

      head []
      *** Exception: Prelude.head: empty list



      So what is a total function?




      Well, basically the opposite, is a function that will work for any input of that type, an example in python:



      def addElem(xs, x):
      xs.append(x)
      return xs


      and this work even for infinite list, if you make a little trick:



      def infiniList():
      count = 0
      ls = []
      while True:
      yield ls
      count += 1
      ls.append(count)

      ls = infiniList()
      for i in range(5):
      rs = next(ls)

      print(rs, addElem(rs,6))

      [1, 2, 3, 4]
      [1, 2, 3, 4, 5] [1, 2, 3, 4, 5]


      in Haskell



      addElem :: a -> [a] -> [a]
      addElem x xs = x : xs

      addElem 3 (take 10 [1..])
      => [3,1,2,3,4,5,6,7,8,9,10]


      That's is for the functions doesn't hangs forever, but the concept is the same, for every list, the function will work.






      share|improve this answer





























        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );














        draft saved

        draft discarded
















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f58339040%2fwhat-exactly-is-meant-by-partial-function-in-functional-programming%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown


























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        16


















        You are here confusing two concepts. A partially applied function [haskell-wiki] with a partial function [haskell-wiki].



        A partially applied function is:




        Partial application in Haskell involves passing less than the full number of arguments to a function that takes multiple arguments.




        whereas a partial function indeed is a non-total function:




        A partial function is a function that is not defined for all possible arguments of the specified type.







        share|improve this answer






























          16


















          You are here confusing two concepts. A partially applied function [haskell-wiki] with a partial function [haskell-wiki].



          A partially applied function is:




          Partial application in Haskell involves passing less than the full number of arguments to a function that takes multiple arguments.




          whereas a partial function indeed is a non-total function:




          A partial function is a function that is not defined for all possible arguments of the specified type.







          share|improve this answer




























            16














            16










            16









            You are here confusing two concepts. A partially applied function [haskell-wiki] with a partial function [haskell-wiki].



            A partially applied function is:




            Partial application in Haskell involves passing less than the full number of arguments to a function that takes multiple arguments.




            whereas a partial function indeed is a non-total function:




            A partial function is a function that is not defined for all possible arguments of the specified type.







            share|improve this answer














            You are here confusing two concepts. A partially applied function [haskell-wiki] with a partial function [haskell-wiki].



            A partially applied function is:




            Partial application in Haskell involves passing less than the full number of arguments to a function that takes multiple arguments.




            whereas a partial function indeed is a non-total function:




            A partial function is a function that is not defined for all possible arguments of the specified type.








            share|improve this answer













            share|improve this answer




            share|improve this answer










            answered 11 hours ago









            Willem Van OnsemWillem Van Onsem

            195k19 gold badges183 silver badges277 bronze badges




            195k19 gold badges183 silver badges277 bronze badges


























                9


















                A partial function (both in the context of functional programming and mathematics) is exactly what the wiki says: a function not defined for all of its possible arguments. In the context of programming, we usually interpret "not defined" as one of several things, including undefined behaviour, exceptions or non-termination.



                An example of a partial function would be integer division, which is not defined if the divisor is 0 (in Haskell it will throw an error).




                in above snippet new_function is partial function.




                That code would simply cause an error in Python, but if it worked as you intended, it would be a total (meaning not partial) function.



                As commentors already pointed out, you're most likely thinking of the fact that it'd be a partially applied function.






                share|improve this answer






























                  9


















                  A partial function (both in the context of functional programming and mathematics) is exactly what the wiki says: a function not defined for all of its possible arguments. In the context of programming, we usually interpret "not defined" as one of several things, including undefined behaviour, exceptions or non-termination.



                  An example of a partial function would be integer division, which is not defined if the divisor is 0 (in Haskell it will throw an error).




                  in above snippet new_function is partial function.




                  That code would simply cause an error in Python, but if it worked as you intended, it would be a total (meaning not partial) function.



                  As commentors already pointed out, you're most likely thinking of the fact that it'd be a partially applied function.






                  share|improve this answer




























                    9














                    9










                    9









                    A partial function (both in the context of functional programming and mathematics) is exactly what the wiki says: a function not defined for all of its possible arguments. In the context of programming, we usually interpret "not defined" as one of several things, including undefined behaviour, exceptions or non-termination.



                    An example of a partial function would be integer division, which is not defined if the divisor is 0 (in Haskell it will throw an error).




                    in above snippet new_function is partial function.




                    That code would simply cause an error in Python, but if it worked as you intended, it would be a total (meaning not partial) function.



                    As commentors already pointed out, you're most likely thinking of the fact that it'd be a partially applied function.






                    share|improve this answer














                    A partial function (both in the context of functional programming and mathematics) is exactly what the wiki says: a function not defined for all of its possible arguments. In the context of programming, we usually interpret "not defined" as one of several things, including undefined behaviour, exceptions or non-termination.



                    An example of a partial function would be integer division, which is not defined if the divisor is 0 (in Haskell it will throw an error).




                    in above snippet new_function is partial function.




                    That code would simply cause an error in Python, but if it worked as you intended, it would be a total (meaning not partial) function.



                    As commentors already pointed out, you're most likely thinking of the fact that it'd be a partially applied function.







                    share|improve this answer













                    share|improve this answer




                    share|improve this answer










                    answered 11 hours ago









                    sepp2ksepp2k

                    312k42 gold badges613 silver badges631 bronze badges




                    312k42 gold badges613 silver badges631 bronze badges
























                        3


















                        The answers explain all, I will just add one example in each language:



                        def add(x,y):
                        return x+y

                        f = add(1)
                        print(f(3))

                        f = add(1)
                        TypeError: add() missing 1 required positional argument: 'y'


                        this is neither a partial function nor a curried function, is a function that you didn't gave all its arguments.



                        a curried function like in Haskell should be:



                        partialAdd= lambda x: lambda y: x + y

                        plusOne = partialAdd(1)
                        print(plusOne(3))

                        4


                        and in haskell:



                        plus :: Int -> Int -> Int
                        plus x y = x + y

                        plusOne = plus 1

                        plusOne 4

                        5


                        A partial function in python:



                        def first(ls):
                        return ls[0]

                        print(first([2,4,5]))
                        print(first([]))



                        output




                        2

                        print(first([]))
                        File "main.py", line 2, in first
                        return ls[0]
                        IndexError: list index out of range


                        And in Haskell, as your link showed up:



                        head [1,2,3]
                        3

                        head []
                        *** Exception: Prelude.head: empty list



                        So what is a total function?




                        Well, basically the opposite, is a function that will work for any input of that type, an example in python:



                        def addElem(xs, x):
                        xs.append(x)
                        return xs


                        and this work even for infinite list, if you make a little trick:



                        def infiniList():
                        count = 0
                        ls = []
                        while True:
                        yield ls
                        count += 1
                        ls.append(count)

                        ls = infiniList()
                        for i in range(5):
                        rs = next(ls)

                        print(rs, addElem(rs,6))

                        [1, 2, 3, 4]
                        [1, 2, 3, 4, 5] [1, 2, 3, 4, 5]


                        in Haskell



                        addElem :: a -> [a] -> [a]
                        addElem x xs = x : xs

                        addElem 3 (take 10 [1..])
                        => [3,1,2,3,4,5,6,7,8,9,10]


                        That's is for the functions doesn't hangs forever, but the concept is the same, for every list, the function will work.






                        share|improve this answer
































                          3


















                          The answers explain all, I will just add one example in each language:



                          def add(x,y):
                          return x+y

                          f = add(1)
                          print(f(3))

                          f = add(1)
                          TypeError: add() missing 1 required positional argument: 'y'


                          this is neither a partial function nor a curried function, is a function that you didn't gave all its arguments.



                          a curried function like in Haskell should be:



                          partialAdd= lambda x: lambda y: x + y

                          plusOne = partialAdd(1)
                          print(plusOne(3))

                          4


                          and in haskell:



                          plus :: Int -> Int -> Int
                          plus x y = x + y

                          plusOne = plus 1

                          plusOne 4

                          5


                          A partial function in python:



                          def first(ls):
                          return ls[0]

                          print(first([2,4,5]))
                          print(first([]))



                          output




                          2

                          print(first([]))
                          File "main.py", line 2, in first
                          return ls[0]
                          IndexError: list index out of range


                          And in Haskell, as your link showed up:



                          head [1,2,3]
                          3

                          head []
                          *** Exception: Prelude.head: empty list



                          So what is a total function?




                          Well, basically the opposite, is a function that will work for any input of that type, an example in python:



                          def addElem(xs, x):
                          xs.append(x)
                          return xs


                          and this work even for infinite list, if you make a little trick:



                          def infiniList():
                          count = 0
                          ls = []
                          while True:
                          yield ls
                          count += 1
                          ls.append(count)

                          ls = infiniList()
                          for i in range(5):
                          rs = next(ls)

                          print(rs, addElem(rs,6))

                          [1, 2, 3, 4]
                          [1, 2, 3, 4, 5] [1, 2, 3, 4, 5]


                          in Haskell



                          addElem :: a -> [a] -> [a]
                          addElem x xs = x : xs

                          addElem 3 (take 10 [1..])
                          => [3,1,2,3,4,5,6,7,8,9,10]


                          That's is for the functions doesn't hangs forever, but the concept is the same, for every list, the function will work.






                          share|improve this answer






























                            3














                            3










                            3









                            The answers explain all, I will just add one example in each language:



                            def add(x,y):
                            return x+y

                            f = add(1)
                            print(f(3))

                            f = add(1)
                            TypeError: add() missing 1 required positional argument: 'y'


                            this is neither a partial function nor a curried function, is a function that you didn't gave all its arguments.



                            a curried function like in Haskell should be:



                            partialAdd= lambda x: lambda y: x + y

                            plusOne = partialAdd(1)
                            print(plusOne(3))

                            4


                            and in haskell:



                            plus :: Int -> Int -> Int
                            plus x y = x + y

                            plusOne = plus 1

                            plusOne 4

                            5


                            A partial function in python:



                            def first(ls):
                            return ls[0]

                            print(first([2,4,5]))
                            print(first([]))



                            output




                            2

                            print(first([]))
                            File "main.py", line 2, in first
                            return ls[0]
                            IndexError: list index out of range


                            And in Haskell, as your link showed up:



                            head [1,2,3]
                            3

                            head []
                            *** Exception: Prelude.head: empty list



                            So what is a total function?




                            Well, basically the opposite, is a function that will work for any input of that type, an example in python:



                            def addElem(xs, x):
                            xs.append(x)
                            return xs


                            and this work even for infinite list, if you make a little trick:



                            def infiniList():
                            count = 0
                            ls = []
                            while True:
                            yield ls
                            count += 1
                            ls.append(count)

                            ls = infiniList()
                            for i in range(5):
                            rs = next(ls)

                            print(rs, addElem(rs,6))

                            [1, 2, 3, 4]
                            [1, 2, 3, 4, 5] [1, 2, 3, 4, 5]


                            in Haskell



                            addElem :: a -> [a] -> [a]
                            addElem x xs = x : xs

                            addElem 3 (take 10 [1..])
                            => [3,1,2,3,4,5,6,7,8,9,10]


                            That's is for the functions doesn't hangs forever, but the concept is the same, for every list, the function will work.






                            share|improve this answer
















                            The answers explain all, I will just add one example in each language:



                            def add(x,y):
                            return x+y

                            f = add(1)
                            print(f(3))

                            f = add(1)
                            TypeError: add() missing 1 required positional argument: 'y'


                            this is neither a partial function nor a curried function, is a function that you didn't gave all its arguments.



                            a curried function like in Haskell should be:



                            partialAdd= lambda x: lambda y: x + y

                            plusOne = partialAdd(1)
                            print(plusOne(3))

                            4


                            and in haskell:



                            plus :: Int -> Int -> Int
                            plus x y = x + y

                            plusOne = plus 1

                            plusOne 4

                            5


                            A partial function in python:



                            def first(ls):
                            return ls[0]

                            print(first([2,4,5]))
                            print(first([]))



                            output




                            2

                            print(first([]))
                            File "main.py", line 2, in first
                            return ls[0]
                            IndexError: list index out of range


                            And in Haskell, as your link showed up:



                            head [1,2,3]
                            3

                            head []
                            *** Exception: Prelude.head: empty list



                            So what is a total function?




                            Well, basically the opposite, is a function that will work for any input of that type, an example in python:



                            def addElem(xs, x):
                            xs.append(x)
                            return xs


                            and this work even for infinite list, if you make a little trick:



                            def infiniList():
                            count = 0
                            ls = []
                            while True:
                            yield ls
                            count += 1
                            ls.append(count)

                            ls = infiniList()
                            for i in range(5):
                            rs = next(ls)

                            print(rs, addElem(rs,6))

                            [1, 2, 3, 4]
                            [1, 2, 3, 4, 5] [1, 2, 3, 4, 5]


                            in Haskell



                            addElem :: a -> [a] -> [a]
                            addElem x xs = x : xs

                            addElem 3 (take 10 [1..])
                            => [3,1,2,3,4,5,6,7,8,9,10]


                            That's is for the functions doesn't hangs forever, but the concept is the same, for every list, the function will work.







                            share|improve this answer















                            share|improve this answer




                            share|improve this answer








                            edited 9 hours ago

























                            answered 9 hours ago









                            Damián Rafael LatteneroDamián Rafael Lattenero

                            12.7k2 gold badges21 silver badges50 bronze badges




                            12.7k2 gold badges21 silver badges50 bronze badges































                                draft saved

                                draft discarded















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f58339040%2fwhat-exactly-is-meant-by-partial-function-in-functional-programming%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown









                                Popular posts from this blog

                                Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                                Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                                François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480