"Well, maybe on a Saturday night, when you've been out, you try and put all 3 inputs in at the same time.." Graham is so funny without even trying to be. His explanations are always on point, too. Great video.
The fact that functions in Haskell are curried by default explains the function signatures with multiple arrows. "add x y = x+y" has the type *"Integer -> Integer -> Integer"* A function that takes and Int and produces another function that takes another Int and produces an Int "add (x y) = x + y" has the type "(Integer, Integer) -> Integer" - Like you would expect in Java "int add(int x, int y) {return x + y;}". By the way, that notation is a fancy way to write "add pair = (first pair) + (second pair)". It really only has *one* parameter "pair".
So the truth what is underlying here "functions are exactly take only one argument". When you call a function with two arguments, you are actually calling a function with one "pair".
@@alpergunes6380 In Haskell you could create a multi-argument function, by passing it a list or a tuple. That's what I have done in the "Java" example. In actual Java, you can have multiple parameters. Typically in Haskell, you wouldn't use tuples or pairs though, but currying, which is different. In currying you pass the first argument to a function with one argument, which then returns another function and then you pass the second argument to that new function to get the end result. x = add 4 5 is the same as x = (add(4))(5) t = add(4) -- t is a "4 adder" x = t(5) -- putting 5 in a 4-adder gives 9
It's not `add (x y)`, it's `add (x, y)`. The comma is important. Without it, `add (x y)` means `(add . x) y`. I.e. apply x to y, then apply `add` to the result.
The point of the notation is to make it explicit that a curried function is a function taking a single argument and then returns a function. By including the explicit lambda notation it ismuch more clear that what is returned is actually a function that takes the next argument. The notation is not difficult. foo x = x is the same as foo = \x -> x
There is failyr standard lambda-calculus notation, e.g. f = λx.x But I agree, that Haskell notation doesn’t make any sense to someone who doesn’t know Haskell.
@@lawrencedoliveiro9104 it does make perfect sense for those who know about maths though. It's like arrow functions in JavaScript, the notation make it very clear that the function is something that given an argument x, returns something that depends on x.
I think this is actually the first video with him that wasn't totally pointless and boring for people who don't know Haskell (nor have any interest in learning it)
I know but to think about curried functions I think you need to think in terms of assembly line where you can change what line does by changing a part of it it's not the only way maybe you can use callback but you must consider also that this is a mathematical way of thinking maybe those are wrong reasons or maybe there are other reasons I'm not sure but that's how I think about it
When he was starting to explain the curry with the add function I was really expecting this example. The map example wasn't wrong but much more complicated than it needed to be.
I think your example is better, than what the video gave, but I still don't see any use for this feature. The normal way is more clear and practically equally long: add(x, y) = x + y addFour(x) = add(x, 4)
You should know that you're the first person who has successfully managed to get me to understand a shred of functional programming. Many have tried. Thank you!
This is probably the simplest explanation of currying: Regular functions take all of the inputs at once. Curried functions take one input and return another function that takes the next input (or the result if it's the last input).
@@Twisted_Code Of course. The ¤ symbol is used when you're talking about an unspecified currency (not euros or dollars, but a hypothetical unit). I think it'd look neat in a real world situation
I feel like he skipped over a pretty big reason you would even want to use currying, which is being able to "pre-compute" (there's got to be actual terminology for this) part of your function, potentially saving you a lot of computation over multiple iterations. Similar to memoization, except that in this case the function itself is acting as your "cache". Or am I completely wrong here?
I've used this with spline interpolation once. Interpolation involves solving a system of linear equations, a fairly expensive process, but once it's done you can use the results to compute the interpolated value in any number of points. So using currying felt like an obvious choice. I've done the same assignment also in C, and it sure felt nice to be able to say at the end of the process: now I have a function from reals to reals, don't worry about the details.
It can be seen as a memoization of its partially applied arguments. In the case of Haskell, it really doesn't matter, because it's a pure functional language so values get memoized automagically (e.g. when `factorial 100` is called first time, it gets computed, but if `factorial 100` is needed again, anywhere, result is just loaded from memory and it won't be computed again).
When I heard of it the first time, the problem to solve was: how to have multiple parameters functions in a language that just allow single parameter functions (aka lambda calculus). That is pretty big.
As someone who is not a programmer it is curious about it, this video is the first time I’ve actually understood fundamentally how functional programming is different from object oriented programming and how it could be useful. It just made something in my brain click. Although reading the other comments made me confused again.
I never knew about curried functions. At the beginning I was sceptic about being an April Fools video. The conviction grew, then I realized it made sense.
It does sound like it could be a joke, especially with the thumbnail. Still, it's actually pretty useful to realise currying/partial application is a thing. Wish they'd delayed it a bit because I bet some people skipped the video thinking it's a joke.
So it works exactly as a state machine? Takes in a single parameter at a time and updates it's internal state accordingly until it completes it's purpose
One example that helped me to understand currying in Haskell: (>) is defined as: Ord a => a -> a -> Bool filter is defined as: (a -> Bool) -> [a] -> [a] If you want to filter all elements > 4 from a list, you can do it like so: filter (>4) [1..10] Since (>4), which is curried, is defined as: (Ord a, Num a) => a -> Bool It can be passed to filter.
Computerphile and Graham Hutton have been delivering quite a nice slew of videos lately. Would you mind grouping them into a playlist? Would be easier to know if I'm missing something.
Does Haskell automatically memoize curried functions? Like if `add x` did some expensive calculation, and you stored `addFive = add 5`, would addFive 7 re-perform the calculation? In JS the args would be captured in the closure, but all the execution would repeat.
Being new to Haskell (I've heard of it but haven't really familiarized myself with its syntax), that initial example of currying confused me a bit. Perhaps it would have been better if he first expressed it explicitly with lambda functions.
1. I didn't get 4:28 - it's literally saying you should didn't give two values , so how does that prove the point about not needing to give two values at the same time? 2. The example at the end finally made something click - will now watch it all a second and possibly a third time! 3. Second viewing and I'm now even more confused. Weill look for another video.
@@Bestape speed depends on the implementation, not the concept. The ghc (glaskow haskell compiler) is very efficient and can produce very fast and optimized programs.
The examples don't really explain what the difference of input arriving one at a time vs all at once from a software point of view. To me they are the same. This makes sense if is applied to a real hardware. Am I to understand that this curried function is generally more applicable to hardware implementations?
I think Swift’s syntax makes most sense. You can see clearly what types are expected in the definition: func plus(_ a: Int) -> (_ b: Int) -> Int { return { b in return a + b } } let plus5 = plus(5) // (Int) -> Int plus(5)(4) // 9 plus5(4) // 9
@@evergreen- If you put the type definition with the function in Haskell, it's even easier to see what's happening IMHO plus :: Int -> Int -> Int plus a b = a + b -- or plus = \a -> \b -> a + b Putting the type definition above top-level functions is common practice in Haskell, he just didn't do it because it was in a REPL and explaining types wasn't in the scope of the video.
That's because Haskell's error messages are dreadful! Elm (a language based on Haskell) does a *much* better job, but only transpiles to JS, so its area of usage is different.
I think a 'curried' function falls into the category of something that most programmers know and use often but doesn't know to call them 'curried' functions. I actually find not naming some things in computer science to be more beneficial for communication rather than obfuscating frequent, naturally arising patterns behind unnecessary jargon. Jagged arrays in C# is another example.
In C you use function pointers. The syntax is pretty horrible, but it can be done. But more to the point, you just don't do this in C, or any of those other languages you mentioned, because it's not idiomatic. Haskell programmers expect you to use currying because that's part of how you program Haskell, just like Scheme programmers expect you to use closures to accomplish more-or-less the same thing (more verbose syntax, but more flexible). Try currying in most C-family languages and all you cause is confusion, because if you're using currying in those languages then you're doing it wrong. The languages weren't intended for that paradigm, and other programmers will struggle to follow your logic.
Is it just me or are curried functions just internal state with more steps? Not very functional of them... But in all seriousness, thanks for the simple explanation.
@Mike Yeah that makes sense. I was thinking that the state was changing, but in the case of add, it only changes once and in an entirely predictable way.
They can be really useful when you need to "carry around" a value that you want to use with some additional function later, perhaps long after the original value has gone out of scope. They can also be really confusing :-)
I don’t like pure functional-programming languages, but I like using functional constructs in procedural languages like Python which make them very handy.
To be a computer scientists requires, more or less, one human unit of brain power/memory/time If the job requires less, it's vocabulary will be expanded until it does.
Because it's mentally easier to follow Map (add 5) [1..10] Over Map f [1..10] Where f n = n + 5 It does the same thing, but once you're used to the style, the first version will be preferred :)
Depends on the dialect. As a native Oklahoman, I say Haskell like "has skull" and Pascal with the same a sound as Haskell but the "al" sounds like "owl." I also put inflection on the "Has" in Haskell and the "al" in Pascal.
Hrm, I just checked and apparently Pascal does have function pointers. So you could most likely do currying in Pascal. Not sure why you'd want to, but that's never stopped anyone before.
This seems more a quirk of Haskell, than a fundamental computer science concept. The problem is universal (how to feed parameters to a function one at a time), but the solution doesn't feel universal.
I have a question. When we use our pass code the code moves thought encryption and if the rubbish match the computer understand that we put the correct pass code but how does it understand the pattern lock we use on our smartphone?
Basically, each vertex of the grid gets assigned a number from 0 to 8, zero being in the top left corner, 8 being in the bottom right. A pattern, then, is just a sequence of vertices in the order you need to hit them in. For example, when you swipe across the entire top row and then down the entire right column, creating a right angle shape, the pattern is 0-1-2-5-8. That is then turned into a byte array and stored as an unsalted SHA-1 hash and compared to whatever you put in. Essentially, it works the very much like a passcode.
0:33 shows a visual of what a basic function is, something you assume people know 2:22 demonstrates taking in multiple arguments and passing them into a function collectively then when it comes time to visualize the actual concept you're teaching, nothing is provided. The idea of a function magically waiting for the next input like the cash machine example fails to explain the logic of what's causing it to behave that way from the standpoint of having functions inside of functions whhere each is described as input --> [function] --> output. All the while, explaining the concept using a programming language that statistically used by less than 1% of all programmers rather than choosing to do it in a language that is statistically likely to reach the most viewers, particularly those who want to learn new concepts. I'll never understand how educators are so absurdly bad at educating
The whole world is using Zoom, along with many stories of it being insecure. Do you guys know if this app is safe or tips on how to safely use it? I was a little stunned when my children's school decided to use that as a form of communication.
@@analogueavenue Yes, well, that is why I'm asking if it's a school requirement. Was it the app, or user error? People don't tend to understand security settings.
@K.D.P. Ross I am sorry if the question offends you, but these guys are known in the US for their top notch cybersecurity. The only way to get a question through to them is through UA-cam. It is relevant since zoom went from 3 million users to 200 million. This channel keeps up with current events as well as coding. They are the best.
You say you don't need to give all of their inputs and then it doesn't work and then you continue to say it works without all the inputs even though it didn't?
Started off strong, then once he got to the curried function itself, there was no explanation of why or where you would use this or even a demonstration of the function that was written.
To show how much javascript has evolved in relation to the above and how similar it is to the arrow functions he was making: const add = x => y => x + y add(2)(3) The older way of doing it: var add = function(x){ return function(y){ return x+y } } add(2)(3) And finally, performing a spread operation to functional arguments (aka, an unknown amount of arguments): const add = (...args) => args.reduce((x, y) => x+y) add(2,3,4,5,6,7,8)
"Well, maybe on a Saturday night, when you've been out, you try and put all 3 inputs in at the same time.."
Graham is so funny without even trying to be. His explanations are always on point, too. Great video.
The fact that functions in Haskell are curried by default explains the function signatures with multiple arrows.
"add x y = x+y" has the type *"Integer -> Integer -> Integer"* A function that takes and Int and produces another function that takes another Int and produces an Int
"add (x y) = x + y" has the type "(Integer, Integer) -> Integer" - Like you would expect in Java "int add(int x, int y) {return x + y;}".
By the way, that notation is a fancy way to write "add pair = (first pair) + (second pair)". It really only has *one* parameter "pair".
So the truth what is underlying here "functions are exactly take only one argument". When you call a function with two arguments, you are actually calling a function with one "pair".
@@alpergunes6380 In Haskell you could create a multi-argument function, by passing it a list or a tuple. That's what I have done in the "Java" example. In actual Java, you can have multiple parameters.
Typically in Haskell, you wouldn't use tuples or pairs though, but currying, which is different.
In currying you pass the first argument to a function with one argument, which then returns another function and then you pass the second argument to that new function to get the end result.
x = add 4 5
is the same as
x = (add(4))(5)
t = add(4) -- t is a "4 adder"
x = t(5) -- putting 5 in a 4-adder gives 9
It's not `add (x y)`, it's `add (x, y)`. The comma is important. Without it, `add (x y)` means `(add . x) y`. I.e. apply x to y, then apply `add` to the result.
0:10 _"... which sound a bit spicy, but are actually very useful."_
excellent delivery, Professor Hutton.
8:57 *Looks at perfectly understandable expression* "Let's make it clear what's going on",
*writes Haskel notation gibberish*
The point of the notation is to make it explicit that a curried function is a function taking a single argument and then returns a function. By including the explicit lambda notation it ismuch more clear that what is returned is actually a function that takes the next argument.
The notation is not difficult. foo x = x is the same as foo = \x -> x
There is failyr standard lambda-calculus notation, e.g.
f = λx.x
But I agree, that Haskell notation doesn’t make any sense to someone who doesn’t know Haskell.
@@lawrencedoliveiro9104 it does make perfect sense for those who know about maths though.
It's like arrow functions in JavaScript, the notation make it very clear that the function is something that given an argument x, returns something that depends on x.
I think this is actually the first video with him that wasn't totally pointless and boring for people who don't know Haskell (nor have any interest in learning it)
I miss an (I think) intuitive example I use often to demonstrate currying. Something like:
add x y = x + y
addFour = add 4
addFour 5
9
addFour 6
10
This makes more sense than the entire video
I know but to think about curried functions I think you need to think in terms of assembly line where you can change what line does by changing a part of it it's not the only way maybe you can use callback but you must consider also that this is a mathematical way of thinking maybe those are wrong reasons or maybe there are other reasons I'm not sure but that's how I think about it
When he was starting to explain the curry with the add function I was really expecting this example. The map example wasn't wrong but much more complicated than it needed to be.
This example would have been the perfect ending to the video, thank you for posting it :)
I think your example is better, than what the video gave, but I still don't see any use for this feature. The normal way is more clear and practically equally long:
add(x, y) = x + y
addFour(x) = add(x, 4)
I will call them "Schönfinkeled functions' from now on.
You should know that you're the first person who has successfully managed to get me to understand a shred of functional programming. Many have tried. Thank you!
Prof. Hutton has a real gift for making complicated concepts easy to understand for
First time I've actually understood currying - or at least, I'm starting to understand it now. Many thanks.
This is probably the simplest explanation of currying:
Regular functions take all of the inputs at once.
Curried functions take one input and return another function that takes the next input (or the result if it's the last input).
This makes javascripting easier
I demand the new world currency must be the Brailsford (with the generic currency ¤ as its symbol)
that's no generic currency, it's dwarf bucks!
okay I must be missing context here. Care to explain?
@@Twisted_Code that's the symbol used for currency in the video game dwarf fortress, the community calls it dwarf or dorf bucks :)
@@Twisted_Code Of course.
The ¤ symbol is used when you're talking about an unspecified currency (not euros or dollars, but a hypothetical unit). I think it'd look neat in a real world situation
I'm still not following how this all relates to the video? Are you referring to the cash machine part of the video?
Great explanation. I like how you explain how to apply this to the map function, this makes the concept clear.
I feel like he skipped over a pretty big reason you would even want to use currying, which is being able to "pre-compute" (there's got to be actual terminology for this) part of your function, potentially saving you a lot of computation over multiple iterations. Similar to memoization, except that in this case the function itself is acting as your "cache". Or am I completely wrong here?
I've used this with spline interpolation once. Interpolation involves solving a system of linear equations, a fairly expensive process, but once it's done you can use the results to compute the interpolated value in any number of points. So using currying felt like an obvious choice. I've done the same assignment also in C, and it sure felt nice to be able to say at the end of the process: now I have a function from reals to reals, don't worry about the details.
You mean partial evaluation?
It can be seen as a memoization of its partially applied arguments. In the case of Haskell, it really doesn't matter, because it's a pure functional language so values get memoized automagically (e.g. when `factorial 100` is called first time, it gets computed, but if `factorial 100` is needed again, anywhere, result is just loaded from memory and it won't be computed again).
When I heard of it the first time, the problem to solve was: how to have multiple parameters functions in a language that just allow single parameter functions (aka lambda calculus). That is pretty big.
It is called partial application function
As someone who is not a programmer it is curious about it, this video is the first time I’ve actually understood fundamentally how functional programming is different from object oriented programming and how it could be useful. It just made something in my brain click.
Although reading the other comments made me confused again.
Very clear explanation of curried functions, higher-order functions, and lambda expressions, worth the 10 min watch!
I never knew about curried functions. At the beginning I was sceptic about being an April Fools video.
The conviction grew, then I realized it made sense.
It does sound like it could be a joke, especially with the thumbnail. Still, it's actually pretty useful to realise currying/partial application is a thing. Wish they'd delayed it a bit because I bet some people skipped the video thinking it's a joke.
that's a funny topic to pick on april first, there are people who won't think this is a real thing.
That's why i'm watching this video lol
Exactly. I was hoping for a 1 April joke. Noop
There's no way Haskell can be a real thing.
Yeah this april 1st joke is BOOORING
Excellent video - should be on the tutorial page for Haskell. Well-explained, understandable but not overly simplified or verbose.
You made me understand at exactly 6:20 - 6:30, it's so clever! Thank you!
Just what I needed. Been a bit confused witn curried function or high order function.
Cash machine example made it all come together!
Take a shot every time he says "function".
did this, am currently having my stomach pumped
Well given he is talking about a functional programming concept, I hope you don't get alcohol poisoning from that.
Edit: welp, too late.
chjAlleNge aCCcepted
1 shot, 2 shots, 3 shots, floor.
those functional programmers and their functions...
This video actually made me hungry for hearing curried so many times
The best functional programming teacher out there!
Thanks for having Mr. Fincher as a guest I love his work
Wow, the example of the cash machine made so easier to understand this! Thank you so much!
Thank you, thank you, thank you for breaking it down with the cash machine problem.
This is very clear. The motivating cm example at the end was extremely helpful. Thanks!
loved the cash machine example! great video!
Hey, can you make a video explaining root files and the CERN ROOT system? it's slightly more complex than i thought it would be
Thank you very much for clear explanations to understand the topic
So it works exactly as a state machine? Takes in a single parameter at a time and updates it's internal state accordingly until it completes it's purpose
simple yet very helpful indeed, thank you
One example that helped me to understand currying in Haskell:
(>) is defined as: Ord a => a -> a -> Bool
filter is defined as: (a -> Bool) -> [a] -> [a]
If you want to filter all elements > 4 from a list, you can do it like so:
filter (>4) [1..10]
Since (>4), which is curried, is defined as: (Ord a, Num a) => a -> Bool
It can be passed to filter.
Computerphile and Graham Hutton have been delivering quite a nice slew of videos lately. Would you mind grouping them into a playlist? Would be easier to know if I'm missing something.
Thank you very much for the very clear explanation!
Excellent explanation of currying and even better comic timing!!
Does Haskell automatically memoize curried functions? Like if `add x` did some expensive calculation, and you stored `addFive = add 5`, would addFive 7 re-perform the calculation? In JS the args would be captured in the closure, but all the execution would repeat.
No, but it does do inlining when possible, which is even more efficient than memoizing.
this is really a very easy to understand explaination, much thanks !!
Being new to Haskell (I've heard of it but haven't really familiarized myself with its syntax), that initial example of currying confused me a bit. Perhaps it would have been better if he first expressed it explicitly with lambda functions.
Study with zoom day 10:🤦
Computerphile new video:💃
1. I didn't get 4:28 - it's literally saying you should didn't give two values , so how does that prove the point about not needing to give two values at the same time?
2. The example at the end finally made something click - will now watch it all a second and possibly a third time!
3. Second viewing and I'm now even more confused. Weill look for another video.
The cashmachine is a very good example
thank you for the great content :D
Is there a practical difference other than maybe speed and brevity between this and getting the same result via nested functions with if statements?
Function composition and higher order functions
@@sdsdfdu4437 Thanks! I think that's what I mean by brevity and speed but in reverse order. I'm assuming higher order is slower.
@@Bestape speed depends on the implementation, not the concept. The ghc (glaskow haskell compiler) is very efficient and can produce very fast and optimized programs.
The examples don't really explain what the difference of input arriving one at a time vs all at once from a software point of view. To me they are the same. This makes sense if is applied to a real hardware. Am I to understand that this curried function is generally more applicable to hardware implementations?
Haskell doesnt help explain these concepts. Something with a less esoteric syntax would be more understandable. From a haskell programmer.
Yea it's a ibt weird they chose this. Maybe they did it because Haskell is a functional language?
@Sydney Bean JavaScript perhaps?
const f = x => y => x + y ?
@Sydney Bean
From ruby-doc.org:
def foo(a,b,c)
[a, b, c]
end
proc = self.method(:foo).curry
proc2 = proc.call(1, 2) #=> #
proc2.call(3) #=> [1,2,3]
I think Swift’s syntax makes most sense. You can see clearly what types are expected in the definition:
func plus(_ a: Int) -> (_ b: Int) -> Int {
return { b in
return a + b
}
}
let plus5 = plus(5) // (Int) -> Int
plus(5)(4) // 9
plus5(4) // 9
@@evergreen- If you put the type definition with the function in Haskell, it's even easier to see what's happening IMHO
plus :: Int -> Int -> Int
plus a b = a + b
-- or plus = \a -> \b -> a + b
Putting the type definition above top-level functions is common practice in Haskell, he just didn't do it because it was in a REPL and explaining types wasn't in the scope of the video.
why does it give an error instead of maybe a little description saying that it's returned a function?
That's because Haskell's error messages are dreadful! Elm (a language based on Haskell) does a *much* better job, but only transpiles to JS, so its area of usage is different.
concept in python:
```
def curried_f(x):
return lambda y: x + y
print(curried_f(2)(3))
```
Is there a real need for flow charts to aid in programming? Or does it not really help with the move to object oriented programming.
one of the cool things about functional programming is that it's easier to capture in a flowchart than imperative programming
@@xybersurfer I guess, but I could always keep track of what I was doing without one. I suppose if my higher-ups wanted one I could make one.
Curried function, sounds a bit spicy. I see what you did there!!
"Schönfinkeled functions" sounds so fancy, should rename it :D
5:02 I don't see the point.
Yes, that was a FP pun.
i would say that Schönfinkel's contribution is the most important one to lambda calculus
08:15 Ah, this explains why I am overdrawn!
I think a 'curried' function falls into the category of something that most programmers know and use often but doesn't know to call them 'curried' functions. I actually find not naming some things in computer science to be more beneficial for communication rather than obfuscating frequent, naturally arising patterns behind unnecessary jargon. Jagged arrays in C# is another example.
Also: monads.
"Just take out the brackets" How do you do that in a more C-like language like C, C++, C#, Java, etc.?
You write three functions and run them one after the other. Currying is more of a syntax shorthand than a mathematical truth of the universe.
In C you use function pointers. The syntax is pretty horrible, but it can be done.
But more to the point, you just don't do this in C, or any of those other languages you mentioned, because it's not idiomatic. Haskell programmers expect you to use currying because that's part of how you program Haskell, just like Scheme programmers expect you to use closures to accomplish more-or-less the same thing (more verbose syntax, but more flexible).
Try currying in most C-family languages and all you cause is confusion, because if you're using currying in those languages then you're doing it wrong. The languages weren't intended for that paradigm, and other programmers will struggle to follow your logic.
I've always wondered how HP calculators were programmed.
Robert Hunter HP calculators often throw reverse polish notation into the mix as well...
This video made me hungry... Couldn't find any Curry, so I went with Mexican. It's a bit spicy too, so hope that's acceptable!
This haunted me in uni because professors didn't explain it as well
Is it just me or are curried functions just internal state with more steps? Not very functional of them...
But in all seriousness, thanks for the simple explanation.
@Mike Yeah that makes sense. I was thinking that the state was changing, but in the case of add, it only changes once and in an entirely predictable way.
Thanks for trying, but this video makes curried functions seem unnecessary and confusing...🤔
They can be really useful when you need to "carry around" a value that you want to use with some additional function later, perhaps long after the original value has gone out of scope.
They can also be really confusing :-)
Exactly what I was thinking. He explained what they are clearly enough, but I can never see where I'd care.
functional programming is the most interesting
I don’t like pure functional-programming languages, but I like using functional constructs in procedural languages like Python which make them very handy.
Why use inc if you can have the succ?
does Graham Hutton only have blue gingham shirts?
If a cash machine was a curried function, you bank balance would never change and you could always get another 100 out.
4:51 map (add 1) [1..10]
woah, awesome :)
Thank you so much
It would be easier to follow if you had him as picture in picture in a corner and not constantly switch between him and the code.
So is it similar to decorators one Python?
-quite-amazing-
was rly hoping this would be an april fools curry recipe
So now I know what one is, and even how to define one... But I don't know why they're used.
To be a computer scientists requires, more or less, one human unit of brain power/memory/time
If the job requires less, it's vocabulary will be expanded until it does.
Because it's mentally easier to follow
Map (add 5) [1..10]
Over
Map f [1..10]
Where f n = n + 5
It does the same thing, but once you're used to the style, the first version will be preferred :)
In other words: to create more functionality with as little as code needed.
4:48 *_magic_*
Higher-order function is fun.
8:42 Can we please change our bank notes to look like that
add = \x -> (\y -> add x+y)
Behold the function to add all
Thank you
Methinks the output from a curried function is highly deterministic and immutable.
@MichaelKingsfordGray I was thinking more of the Sunday am thunderbox visit after the Saturday night down the local star of Bengal. 😉😉
Does curry create side effects?
thanks a lot!
Woah, "Haskell" rhymes with "Pascal"?!
Not really. 'el' and 'al' are different
Depends on the dialect. As a native Oklahoman, I say Haskell like "has skull" and Pascal with the same a sound as Haskell but the "al" sounds like "owl." I also put inflection on the "Has" in Haskell and the "al" in Pascal.
Those Haskell error messages need some work :)
The cuts to the black text on white background is giving me a headache...
It's a design pattern btw
8:43 lol comoney
I still don't fully understand why you would even want to use it in js besides for front end.
4:30 This why we shouldn't take photos by toaster
Let's take a finite state machine and hammer it into a functional language digestible format.
0:42 - I thought he said Pascal. I was excited for a moment there. :-|
I thought he said Schoenberg was a "mathematician and magician".
Hrm, I just checked and apparently Pascal does have function pointers. So you could most likely do currying in Pascal.
Not sure why you'd want to, but that's never stopped anyone before.
This seems more a quirk of Haskell, than a fundamental computer science concept. The problem is universal (how to feed parameters to a function one at a time), but the solution doesn't feel universal.
Very interesting
Brilliant
Help.
Javascript does this.
> let add = x=>y=>x+y
x=>y=>x+y
> let add2 = add(2)
y=>x+y
> add2
y=>x+y
> add2(4)
6
WHAT
I have a question.
When we use our pass code the code moves thought encryption and if the rubbish match the computer understand that we put the correct pass code but how does it understand the pattern lock we use on our smartphone?
Basically, each vertex of the grid gets assigned a number from 0 to 8, zero being in the top left corner, 8 being in the bottom right. A pattern, then, is just a sequence of vertices in the order you need to hit them in. For example, when you swipe across the entire top row and then down the entire right column, creating a right angle shape, the pattern is 0-1-2-5-8. That is then turned into a byte array and stored as an unsalted SHA-1 hash and compared to whatever you put in.
Essentially, it works the very much like a passcode.
@@isaactfa thanks I desperately wanted that answer. 😊 you just gained another subscriber.
0:33 shows a visual of what a basic function is, something you assume people know
2:22 demonstrates taking in multiple arguments and passing them into a function collectively
then when it comes time to visualize the actual concept you're teaching, nothing is provided. The idea of a function magically waiting for the next input like the cash machine example fails to explain the logic of what's causing it to behave that way from the standpoint of having functions inside of functions whhere each is described as input --> [function] --> output.
All the while, explaining the concept using a programming language that statistically used by less than 1% of all programmers rather than choosing to do it in a language that is statistically likely to reach the most viewers, particularly those who want to learn new concepts.
I'll never understand how educators are so absurdly bad at educating
The whole world is using Zoom, along with many stories of it being insecure. Do you guys know if this app is safe or tips on how to safely use it? I was a little stunned when my children's school decided to use that as a form of communication.
@@analogueavenue Yes, well, that is why I'm asking if it's a school requirement. Was it the app, or user error? People don't tend to understand security settings.
@K.D.P. Ross I am sorry if the question offends you, but these guys are known in the US for their top notch cybersecurity. The only way to get a question through to them is through UA-cam. It is relevant since zoom went from 3 million users to 200 million. This channel keeps up with current events as well as coding. They are the best.
You say you don't need to give all of their inputs and then it doesn't work and then you continue to say it works without all the inputs even though it didn't?
Started off strong, then once he got to the curried function itself, there was no explanation of why or where you would use this or even a demonstration of the function that was written.
Wanna write super ugly and unreadable code? Write curried functions!
Hey ATM, give my card back
To show how much javascript has evolved in relation to the above and how similar it is to the arrow functions he was making:
const add = x => y => x + y
add(2)(3)
The older way of doing it:
var add = function(x){
return function(y){
return x+y
}
}
add(2)(3)
And finally, performing a spread operation to functional arguments (aka, an unknown amount of arguments):
const add = (...args) => args.reduce((x, y) => x+y)
add(2,3,4,5,6,7,8)