Functors: I was WRONG! - FunFunFunction #11

  Рет қаралды 90,615

Fun Fun Function

Fun Fun Function

Күн бұрын

Пікірлер: 168
@RobertFerentz
@RobertFerentz 9 жыл бұрын
Admitting you were wrong... you'd make a terrible politician. :P
@manualvarado2212
@manualvarado2212 6 жыл бұрын
Hahahaha!
@Yetipfote
@Yetipfote 5 жыл бұрын
wish more politicians would be like that :(
@chromosundrift
@chromosundrift 5 жыл бұрын
@@Yetipfote let's vote for those ones then ;)
@chromosundrift
@chromosundrift 5 жыл бұрын
On a more positive note, admitting you're wrong enables you to learn and makes you more trustworthy to others trying to learn!
@iAmTheSquidThing
@iAmTheSquidThing 8 жыл бұрын
So… In short, a functor is a collection that can be passed a function and apply it nondestructively to all of its elements, returning another functor?
@funfunfunction
@funfunfunction 8 жыл бұрын
+Andy Brice you've just invented the most succinct explanation of it I've ever heard. The only thing I would add is that it returns a functor of the same TYPE.
@iAmTheSquidThing
@iAmTheSquidThing 8 жыл бұрын
funfunfunction Ahh, I guess so that you can chain a bunch of functions together in whatever order, secure in the knowledge that they'll all be operating on the same type of object.
@funfunfunction
@funfunfunction 8 жыл бұрын
+Andy Brice precisely.
@AndersJackson
@AndersJackson 8 жыл бұрын
Same type? You had an array of dragons and then an array of string and last an array of int. They are not the same type. The structure are isomorph, that is, it looks like the original in structure. Where each element is transfered to another type by the function sent to map. Ok, in Java script I belive you are allowed to store mixed types in arrays. And yes, @Andy made a very short and good explanation of a Functor.
@AndersJackson
@AndersJackson 8 жыл бұрын
***** well, actually it isn't. The content type is part of the type. And yes, I know some languages are not that particular about type checking. That they treat Arrays as a generic datatype, where you can store objects of any type. Same with lists. Doesn't change that an array of int and array of char are different types though.
@EivindDahl
@EivindDahl 4 жыл бұрын
In short, a functor is an assignment of, for any type T, a type FT, and for any transformation f : T ---> U a transformation Ff : FT ---> FU subject to certain niceness conditions. Write FT as T[] and Ff as map(f) and you're in business.
@jagk4459
@jagk4459 5 жыл бұрын
Thanks for sharing. I like your videos. It makes my day happier. =) One small suggestion, maybe, you can accompany the video with downloadable notes that is easy to understand for anyone (children etc.), i.e: PDF format. For example, in this video, I learned that functors have three characteristics; 1. Transformation of content 2. Maintain the structure of content 3. Returns a new functor Something like that. Again, thank you very much. I learned a lot from you. =)
@salvacarsimoreno5228
@salvacarsimoreno5228 8 жыл бұрын
You got it really wrong in the previous video haha, even though it help a lot to understand the reason for functors to exist. Thanks for the rectification, its a while I am trying to understand functors and monads and your videos are a big help. Keep on the good work!
@Vintharas
@Vintharas 9 жыл бұрын
Excellent vid! Hilarious as usual and very interesting as well! Function composition FTW! Also very brave to shout to the world that you were wrong :)
@DennisRiungu
@DennisRiungu 7 жыл бұрын
You are simply the best I have watched in a while!! You made me get more serious on functional!!!
@scuden
@scuden 9 жыл бұрын
I absolutely love this guy
@yasinyaqoobi
@yasinyaqoobi 4 жыл бұрын
I think functors must also preserve composition so map (f . g) == map f . map g , which i think means ---> [1,2,3].map(x => double(x)).map(x => square(x)) == [1,2,3].map(x => square(double(x))).
@vbikcl
@vbikcl 9 жыл бұрын
The simplest definition of a functor is an object which acts as a container for a value, which then allows to you APPLY one or more functions to that value, and returns a new functor containing the transformed value. It's not about having a map method per se, it's just the idea of wrapping a simple value in an object that then allows you to "decorate" it with functionality to be evaluated either eagerly, or lazily.
@kevinpeter7202
@kevinpeter7202 7 жыл бұрын
The Kate Beaton pony shirt again. Yay! Also, although there was lots of interesting content regarding functors, the strange dancing Santa hat alone made this video worth watching
@pol...
@pol... 8 жыл бұрын
What about strings in Haskell where they are defined as a list of characters? You can very well map a function that does, let's say return True if the character is 'a' and False else. In this sense the structure is conserved because you give it a list of Chars and returns a list of any other things (in the example booleans). So doing: let as = map isA "abc" is the same as doing: let as = map isA ['a','b','c'] and as will have the value of [True, False,False] ______________________________ Code example mapFunction :: (a -> b) -> [a] -> [b] mapFunction _ [] = [] mapFunction f (x:xs) = f x : mapFunction f xs isA :: Char -> Bool isA 'a' = True isA _ = False ghci: mapFunction isA "abc" [True, False, False] ______________________________________ So if I am getting this right, strings in Haskell (since they are just a type synonym for [Char]) are functors. Am I right? Could you please help me shine some light on this issue? Btw. Very nice channel and video. I am subscribing. :)
@kaicurry9111
@kaicurry9111 9 жыл бұрын
The hat!!! Thanks for another fantastic video.
@gregsmith80
@gregsmith80 9 жыл бұрын
The last two videos were the best in a while.
@solvm1652
@solvm1652 9 жыл бұрын
Awesome! Thanks for the clarification. Way to handle being "wrong" like a G! You're a developer's developer.
@alihammadshah
@alihammadshah 8 жыл бұрын
Functors are 1-morphism of Objects(A,B...) eg. A -> B in 2-category where objects are categories (1-cat). How come morphism become an object (that implements map), shouldn't the functor be the function that's passed into the map?
@lifematch
@lifematch 8 жыл бұрын
Oh if you come in the c++ land. Functor is basically a class with bunch of operator overloading which makes it seem like a function that can handle multiple arguments.
@pdowner1
@pdowner1 7 жыл бұрын
I am glad to be getting to things I dont understand. seriously, thank you!
@corlaez
@corlaez 4 жыл бұрын
Thank you very much for fixing the mistakes. I respect that.
@Shambo271
@Shambo271 6 жыл бұрын
There is so much confusion around functors and monads and your forthrightness is appreciated.
@SeanForeman
@SeanForeman 6 жыл бұрын
That was great. I eeally enjoyed your explanation of what a functor is and why your prior video was wrong.
@djxak
@djxak 8 жыл бұрын
So, the Functor is just an object, that has a "map" function (where "map function" is a function, that returns new object of the same type and shape)? If that is correct, then the only one required operation of functor is a "map" operation, right?
@karrorri1097
@karrorri1097 4 жыл бұрын
any value on which "map" can be implemented is a functor?
@paganaye
@paganaye 9 жыл бұрын
I understood where you come from. Personnally I will still call the map function a Functor rather than the "high order function". I certainly hope that the functor denomination will stick.
@ladrillopendejo
@ladrillopendejo 9 жыл бұрын
Hi Matt, I was just wondering but did you get that horse shirt online? If so can you tell us all where you got it!!!
@funfunfunction
@funfunfunction 9 жыл бұрын
+ladrillopendejo Glad you asked. It's Pony, one of the characters that the amazing Kate Beaton draws. It's in her store here: www.topatoco.com/merchant.mvc?Screen=CTGY&Store_Code=TO&Category_Code=BEAT She is a comic book author that I'm a very big fan of. Check her out: www.harkavagrant.com/index.php?id=131
@cKFSDev
@cKFSDev 8 жыл бұрын
@3:25 Dat Face hahaha. You are awesome man! Keep it up!
@klausklemper5987
@klausklemper5987 6 жыл бұрын
I love your humor !!:D
@Gabriel-Aggrey
@Gabriel-Aggrey 9 жыл бұрын
what are the things that make up your media station ( mic, camera, software for editing )? please respond
@funfunfunction
@funfunfunction 9 жыл бұрын
Standard KZbin stuff all of it. Midrange DSLR, cheap soft lights, blue yeti, FCPX
@marcnitzsche
@marcnitzsche 8 жыл бұрын
I like watching those videos on 1.5x.
@smbossco
@smbossco 8 жыл бұрын
doesnt the map function take three parameters? the last one being the array itself... or does that not count as a 3rd parameter for some reason?
@NipunaGunathillake
@NipunaGunathillake 9 жыл бұрын
Doesn't filter function transform the content, Maintain structure and can be chained? So does that mean an object containing a filters are functors as well?
@funfunfunction
@funfunfunction 9 жыл бұрын
+Nipuna Gunathillake Map and filter reminds about each other, but they are actually very different. map and filter seem more similar than they are. Filter changes the array structure, not the contents, while map does the opposite. This might be hard to grasp if you are thinking of an array as bunch of items - instead, in your mind, try to separate the concepts of the items and the structure that is the array. Let me explain: Imagine array as a container that looks like this: img1.etsystatic.com/000/0/6248605/il_340x270.329955061.jpg The balls are the array items, and the steel frame that the balls lie in is the array. I know that it's easy to think of array as just a set of items because you can add and remove items from an array in JavaScript, but instead try to separate the items and the structure in your mind. Think of an array not as a set of items, but as a tray that contains the items. The tray is a functor, so it provides a slot on the side, labeled map, into which you can insert a transformation function. If you do, a new tray of the *exact same size* is created, but with all items transformed through the transformation function. The structure, the tray, has NOT been changed, but all items have been changed. There is also a slot for filter, but filter does almost the exact opposite, it passes every item through the filter function, and if the filter function returns true, that items is deemed to make the cut to be in the new tray, which is created. The individual items are NOT transformed (some are thrown away though), but the tray has been changed into a smaller tray.
@NipunaGunathillake
@NipunaGunathillake 9 жыл бұрын
Got it! Thanks for the awesome explanation. Filters change the array(container) not just it's container. It's a bit difficult getting my head around all the functional programming concepts but your videos have definitely made it far more fun! Thanks for all the videos.
@luisraulaceretoricalde4536
@luisraulaceretoricalde4536 9 жыл бұрын
Great channel. I love it. Is it me, or the code for the second example does not work?
@Bigdaddy91982
@Bigdaddy91982 8 жыл бұрын
Just you buddy!
@ericlif1
@ericlif1 4 жыл бұрын
4 years later, it's not just you. Map is not a function declared on Promise prototype object. As you can see on the video, at the very top of the example is using Bluebird (external library) Promise which has a map defined.
@evariste6116
@evariste6116 6 жыл бұрын
Can't make the 'bluebird' example work as listed. Get "Unhandled rejection TypeError:expecting an array or an iterable object but got [object Null]...." (node v10.4.1, bluebird 3.5.2). Adding a reject method to promise only delayed the error! ?....but learnt something in trying so thanks!
@amitkrgupta094
@amitkrgupta094 2 ай бұрын
This was a great video! Thank you
@jnfsmile
@jnfsmile 8 жыл бұрын
If it maintains structure doesn't it follow that it returns a functor? What's the difference between 2 & 3?
@tymon111
@tymon111 8 жыл бұрын
"Secret club became so secret that it has no members" :D
@trex_son5705
@trex_son5705 7 жыл бұрын
in angular 2, is this also considered a functor: this.http.get('....json?auth='+ token) .map(...)
@coolworx
@coolworx 9 жыл бұрын
Am I the only one that thinks the host should experiment with wigs?
@ThePreyBrigade
@ThePreyBrigade 9 жыл бұрын
Possibly. LOL
@47beethoven
@47beethoven 8 жыл бұрын
Yo mpj (or anyone really). Just a question: if i chain maps (sometimes ppl do for the sake of composing), will it traverse the collection multiple times? Like: square_list.map(square => square.base).map(size => Math.pow(size, 2)) (and later i could perform a reduce or whatever for exemple). I mean, it probably should but compilers have cool tricks and all... so i'd sleep better at night if it wouldnt (in the case that the execution of those statements wouldnt produce colateral effects).
@funfunfunction
@funfunfunction 8 жыл бұрын
+47beethoven it will. There is no way for the compiler to optimize this for you in JavaScript, but you can compose the two functions into one before passing it to map and thereby have only a single map. See compose function in the rambda library, for example.
@47beethoven
@47beethoven 8 жыл бұрын
Cool, i will check it out. Nice that you answer questions on year's old videos.
@joseaquino96
@joseaquino96 9 жыл бұрын
Is that a painting of Yoshi in a go cart from Mario Kart in the background? if so, I love it and love your videos, very interesting and relevant subjects, even when they are wrong!
@funfunfunction
@funfunfunction 9 жыл бұрын
It's actually a yoshi made with fuse beads glued to an vintage cross-stitch. It's made by @pappasparlor on Instagram, they are amazing.
@joseaquino96
@joseaquino96 9 жыл бұрын
It is amazing! just started following him on Insta, and thanks for all the videos, been binge watching them
@p4chw1n
@p4chw1n 9 жыл бұрын
I really enjoyed the video (as well as any previous one) but I am paranoid (JSX thaught me that). You have Syntax Error in second example, resolve function missing closing ). You also returning there {{name: 'Fluffykins', health: 70}} which is another syntax error and then call on this value .map() which would throw one more error. As a punishment I sentence you to do this great videos until the universe ends! :)
@funfunfunction
@funfunfunction 9 жыл бұрын
+p4chw1n I accept your punishment! :) Great catch, btw. I actually knew about the first one but ignored it in the edit in favor to get the episode out on time, but the second one completely passed me by.
@alexandersobolev5284
@alexandersobolev5284 8 жыл бұрын
+funfunfunction, I don't think you need to do any transformation to be qualified as a functor. Functor - as mentioned in this video - is a sort of a Container object which has map (for chaining) and flatMap (to unfold the final value when chaining is finished) methods on it. That's it. Check out my own quick functor: const Container = x => ({ map: f => Containter( f ( x ) ), flatMap: f => f( x ) }); But as far as I understand it 'map' method is there just to run a function in the given context. That's it!!! For example, Container( 7 ).map(num => num). I don't modify anything here, I just return the same thing back into my Container. But it's still a functor, because my Container is a functor no matter what function I choose to run in the given context (i.e. whatever function I choose to map).
@azs06
@azs06 8 жыл бұрын
Fun and educational, what else you need.
@bartsmykla
@bartsmykla 9 жыл бұрын
One insignificant hint from me. I like your videos, but think to use another sounds from this YT defaults. I think, that I hear them in almost every YT video. :-D Great video. You are making good work! :-)
@funfunfunction
@funfunfunction 9 жыл бұрын
+Bartłomiej Smykla Not from the KZbin defaults. :)
@bartsmykla
@bartsmykla 9 жыл бұрын
+mpjme Oh, then apologise. But still I hear that so many times a day, so I just thought it's YT defaults. :-D
@peripona
@peripona 8 жыл бұрын
hahahah that sigh, on watching Beard... @3:32
@Goofy8907
@Goofy8907 7 жыл бұрын
Hello everyone, I've been having some trouble with some of the code in the video for some time let Promise = require('bluebird') const whenPkmnIsLoaded = new Promise((resolve, reject) => { setTimeout(() => resolve({ { name: 'Pikachu', type: 'electric' } }, 2000) }); const thing = whenPkmnIsLoaded .map(pkmn => pkmn.name) .then(name => console.log(name)) // Also, I installed bluebird like so: // npm install bluebird --save Where am I screwing up? Thanks
@t0m4_
@t0m4_ 7 жыл бұрын
Hello! I think his example was wrong too, because he gave timeout value to the resolve, instead of setTimeout, also you cant put an object inside of an object like that, that will cause a javascript error, so i've corrected your code and this should work nicely: let Promise = require('bluebird') const whenPkmnIsLoaded = new Promise((resolve, reject) => { setTimeout(() => resolve([ { name: 'Pikachu', type: 'electric' } ]), 2000) }) const thing = whenPkmnIsLoaded .map(pkmn => pkmn.name) .then(names => console.log(names))
@shadowdrakon9913
@shadowdrakon9913 7 жыл бұрын
Goofy8907 I think it may because he’s using ES6
@winterrcore
@winterrcore 6 жыл бұрын
It should be like this, since bluebird's map method expects an iterable. setTimeout(() => resolve([{ name: "Fluffykins"}]), 2000); from what I understood it works just like Array.prototype.map, except that it waits until the promise resolves and you can use it directly So basically this whenDragonLoaded .map(dragon => dragon.name) .then(console.log); Is equivalent to this whenDragonLoaded .then(dragons => dragons.map(dragon => dragon.name)) .then(console.log);
@Abhi_badale
@Abhi_badale 7 жыл бұрын
I enjoy ur videos ... Just one thing that I would like to tell u is please correct that example where u r using promise from bluebird ... One should pass an array of dragon in to resolve function and not single dragon object ...othetwise ur map will fail ... Try it :)
@przemysawlib4309
@przemysawlib4309 8 жыл бұрын
Laws are must have when writing Your own Functor. Braking laws means composition will be broken.
@armanb9778
@armanb9778 7 жыл бұрын
MPJ, can you please bring back the "fluhluhluhluh!" at 2:57? It's the best. EDIT: Actually, "Blehelele!" at 3:28 is best.
@JohnMichaelReed
@JohnMichaelReed 9 жыл бұрын
That was really interesting. So what is a Monad? Because I thought that a Monad was like a composable thing that takes in a function, but then I realized that the thing I thought was a Monad was basically the same as what you are describing.
@funfunfunction
@funfunfunction 9 жыл бұрын
+John Michael Lafayette You will be able to watch that in the upcoming video about monads, and the undoubtedly subsequent video about how I was wrong about monads. :)
@funfunfunction
@funfunfunction 9 жыл бұрын
+mpjme A monad is Functor with some specific behaviour, by the way. That is why I'm explaining functors at all, it's a stepping stone to monad.
@JohnMichaelReed
@JohnMichaelReed 9 жыл бұрын
+mpjme Oh. So the Monad isn't the thing that is doing the propagating. It's the thing that is being propagated (the specific behavior that is being propagated). Monad encapsulates behavior.
@JohnMichaelReed
@JohnMichaelReed 9 жыл бұрын
+mpjme Too soon.
@gabrielvergnaud2432
@gabrielvergnaud2432 9 жыл бұрын
+John Michael Lafayette here is the great mostly adequate guide to functionnal programing from Dr. Boolean, which explains very well what it is => drboolean.gitbooks.io/mostly-adequate-guide/content/ch9.html Basically it's just a wrapper like a functor, with a "join" method on it.
@vedovelli
@vedovelli 9 жыл бұрын
Thanks for the series! It's awesome!
@osakaandrew
@osakaandrew 8 жыл бұрын
If `String` + `map` is not a functor because the `map` only works for string-returning transformations, then JS's Typed Arrays must not be functors either: let x = new UInt8Array([1,2,3,4]); x.map(x => false) // [0, 0, 0, 0] I'm not saying that this distinction is wrong, but that the distinction has to be implementation-specific or the definition is useless. If Typed Arrays are functors (and they must be, to my thinking) then `String+map` must be as well. Just a thought.
@funfunfunction
@funfunfunction 8 жыл бұрын
+Andrew Adamson its not string specifically, it must maintain form. The .map of a Widget must return another Widget, or it is not a functor. If UInt8Array.map would have returned say, a normal array, instead of a UInt8Array then it would violate the functor contact. This is bad because then chainability has been compromised and we would not be able to do: myByteArray.map(someTransformationFunc).buffer()
@cpakken
@cpakken 8 жыл бұрын
Wouldn't chaining on map be non-optimal since it will loop over the array again? (Imagine a very BIG array)
@funfunfunction
@funfunfunction 8 жыл бұрын
+Chris Kwong in a real life situation, you'd chain array.filter().map() if the array was very large and the map was very expensive. But it would have to be very large for that to matter - a modern JS engine on a smartphone is very fast - I just tried and my phone maps over 22 million items per second. I'm not a fan of discussing performance on a line by line level because I don't think that is how performance works (see my elaboration on the topic here kzbin.info/www/bejne/hpm4k2qvbryNfdU).
@elie2222
@elie2222 9 жыл бұрын
Great video as always
@jaimeg.8855
@jaimeg.8855 8 жыл бұрын
where do you get all these cats shirts..gear
@iAmTheSquidThing
@iAmTheSquidThing 8 жыл бұрын
I'm no zoologist, but I'm pretty sure those are horses.
@jaimeg.8855
@jaimeg.8855 8 жыл бұрын
hah yeh im not sure where the cat came from
@blazedb420
@blazedb420 7 жыл бұрын
Your videos rock sir! Thank you
@ChuckJHardy
@ChuckJHardy 7 жыл бұрын
Great episode. Thanks 😜
@AndersRapp
@AndersRapp 8 жыл бұрын
Apart from the great content let me give a shout out to the awesome t-shirts! :-P Also, do a video on prototypes! It might not be functional programming in itself but it's a concept that even the best books (like Learning Ecmascript 6) get confused.
@funfunfunction
@funfunfunction 8 жыл бұрын
+Anders Rapp I have made a video about that already. ;)
@AndersRapp
@AndersRapp 8 жыл бұрын
+funfunfunction I'll go check that out then. Thanks and keep up the good work! :)
@haojiang4882
@haojiang4882 5 жыл бұрын
It makes sense that you used to work in the theatre industry.
@minispecs123
@minispecs123 9 жыл бұрын
could a POJO be a functor?
@funfunfunction
@funfunfunction 9 жыл бұрын
+minispecs123 It could if it implemented map.
@RevisionSeventeen
@RevisionSeventeen 9 жыл бұрын
I think in the parts of this video where you pop up in the back of the room you're out of focus a bit. Other than that great video! Keep up the good work!
@jamma246
@jamma246 6 жыл бұрын
It's pretty simple. A functor is the following: - a type constructor F, which takes one type and returns another (that is, for a type a we have another type F a); - for which we also need some function fmap :: (a -> b) -> (F a -> F b) for all types a and b. That's all it is. But we do require the following two axioms: - if id is the identity map id :: a -> a on the type a (that is, id x = x) then fmap id is the identity map on F a - if f :: a -> b and g :: b -> c, as usual we can compose them to g . f :: a -> c. Then we require that fmap (g . f) = (fmap g) . (fmap f). I come at this more from mathematics, so I think having the axioms is important. But programmers are likely going to be more interested in just _implementing_ functors, so defining the type constructor F and the fmap. It turns out that if you can define a type constructor F and implement the fmap as above, then you only need to check the first axiom to get the second, seemingly more complicated one, for free (I could be wrong about that, but I think this is a so-called "theorem for free". It comes from the restriction of having to define fmap parametrically, so strictly speaking I'm restricting to certain kinds of languages here, like Haskell). The list functor is an example. Given a type a, we can define the type [] a, more commonly written [a], which is the type of lists of elements in a. For example, x = [1,15,-2,3] is an element of [Int]. If you have a map f :: a -> b, then you get in an obvious way a map which takes lists of a's and returns lists of b's: just apply f to each element in the list. For example, if f :: Int -> Int is the times two map, then fmap f x = [2,30,-4,6]. Now applying the identity map to each element of a list gives back the same list, so fmap id is the identity. And if you have two composable functions, f and g, then mapping each element of a list by g after f is the same thing as first applying f to each element of the list, and then applying g to each element of that list. That is, fmap (g . f) = (fmap g) . (fmap f). So the functor axioms are satisfied. Whenever you have a type constructor as above with some parametric fmap implemented, the chances are that it will be a functor.
@mfaine
@mfaine 7 жыл бұрын
+1 for correcting yourself.
@CarlosBaraza
@CarlosBaraza 9 жыл бұрын
So if I understood it right, you Christmas hat is a Monad.
@funfunfunction
@funfunfunction 9 жыл бұрын
+Carlos Baraza Well, it certainly encapsulates some messed up behavior.
@iAmTheSquidThing
@iAmTheSquidThing 8 жыл бұрын
I've started learning Haskell recently. And perhaps the reason for this confusion in the community is that in pure functional programming, the boundaries between objects and functions get a bit blurry. They seem to be both referred to more vaguely as a "computational context" which I think is something slightly esoteric stemming from category theory.
@barbarakendal5739
@barbarakendal5739 7 жыл бұрын
I tried to scroll down to see the rest of the t-shirt :)
@erikw4193
@erikw4193 7 жыл бұрын
that drag at 5:41 tho
@lukewright5544
@lukewright5544 8 жыл бұрын
I like your clips very much and the way how you marry fun and function ;) ever thought about teaching yound "want-to-be"-programmers?!
@funfunfunction
@funfunfunction 8 жыл бұрын
That is who the channel is targeted to. Or rather, programmers that are about 1 year into their first job - that is who I imagine when I make the videos.
@chromosundrift
@chromosundrift 5 жыл бұрын
"if I had a bigger beard... " LOL
@juliankrispel-samsel218
@juliankrispel-samsel218 8 жыл бұрын
I adore your videos
@lifematch
@lifematch 8 жыл бұрын
I like how you say functor!!!
@graymur07
@graymur07 9 жыл бұрын
Actually, callback to Array.prototype.map() takes three arguments. *Flies away to do homework*
@olegon_yt
@olegon_yt 8 жыл бұрын
Hahaha, you're crazy! Awesome video! Thanks!
@kazaakas
@kazaakas 6 жыл бұрын
6:58 According to Brian Lonsdorf (Dr Boolean)'s book, you're making a number one rookie mistake here. Should be: then(console.log) not: then(name => console.log(name)) wrapping stuff like this is redundant.
@funfunfunction
@funfunfunction 6 жыл бұрын
The two are not equivalent because .log is property on the console object and depending on the implementation of console in the runtime environment, I've had what you're suggesting sometimes break, which is why I've adopted the habit to just always wrap the console.log calls in a wrapper.
@mikoajg7534
@mikoajg7534 7 жыл бұрын
I LOVE this!
@joe_3y3s
@joe_3y3s 3 жыл бұрын
I GET IT NOW!! thank you
@leftover7766
@leftover7766 6 жыл бұрын
I bet that pooch runs away next time you whip out your wood. (cause you really screw the pooch!) BUT mistakes often provide more opportunity for learning than slick perfection. I got a LOT out of this.
@anler2b
@anler2b 8 жыл бұрын
Dr. Boolean is just amazing, great recommendation, follow him!
@herp_derpingson
@herp_derpingson 6 жыл бұрын
4:20 The `dragon => dragon.name` is the functor. Functors are basically stateful functions which maintain the state themselves. stackoverflow.com/questions/356950/c-functors-and-their-uses
@IonMasuna
@IonMasuna 7 жыл бұрын
I laughed so hard in the hat part that I cried xDD
@Luxalpa
@Luxalpa 6 жыл бұрын
I approve the dragon objects!
@johnywhy4679
@johnywhy4679 4 жыл бұрын
hi, love your videos, but i won't watch this one or the previous one. As a beginner, listening to wrong information, and then listening to a correction, and then attempting to make sense of it all, will just CONFUSE me. Omg, plz don't tell me i "need" to watch a video that has wrong info in it. i hope you will make one Functor video which is all correct, which isn't littered with "the wrong thing i said in the last video was ..." (GAH, I'M PLUGGING MY EARS!), and is designed to be a complete Intro to Functors which stands on it's own. Hope you understand!
@funfunfunction
@funfunfunction 4 жыл бұрын
hey Johny. Happy that you are learning programming! I understand that you have a need for cohesion and predictability at this point, where everything seems confusing, that must be very stressful. However, other people, me included, also exist and have needs and limitations. :) I did these two videos a weekend on my spare time about five years ago, and while I am pretty proud of this series it's also the very first videos I ever made on programming, and there were some mistakes made. The mistakes are done and there is nothing to be done about it, and mistakes will always be done - I think correcting it was the right way to go. An advice I can give as a programmer is to accept that the world is an inelegant messy place and that it is in fact our job as engineers build systems that give the illusion of elegance to other people. Fundamentally the world is a mess and it's important to remember that a CPU is just a stone that we have managed to somehow flatten an put lightning inside of it.
@nicolasschurmann
@nicolasschurmann 9 жыл бұрын
Fantastic! :)
@yasaamoin4882
@yasaamoin4882 7 жыл бұрын
I need to sleep on this
@Mike-rt2vp
@Mike-rt2vp 7 жыл бұрын
I now have no idea what a functor is... I wanted to simplify it to a function that operates on a collection and takes another function as a argument. But now I have to clean my brain off the floor because it exploded.
@funfunfunction
@funfunfunction 7 жыл бұрын
You might want to look at my functor/monad talk if you're still confused: kzbin.info/www/bejne/aJvTaYFsfcZqqrs
@maxc101
@maxc101 7 жыл бұрын
Haha love ya brother!
@Yetipfote
@Yetipfote 5 жыл бұрын
Idk. Functors are objects that have methods? Sounds a lot like OOP for me not FP where state and operations are separate.
@markuswilson3778
@markuswilson3778 5 жыл бұрын
I need that shirt! xD
@JasonCtutorials
@JasonCtutorials 9 жыл бұрын
HAHA I LOVE THIS GUY!
@krzysztofkabat9166
@krzysztofkabat9166 9 жыл бұрын
To the monad-mobile!
@99vishaal
@99vishaal 3 жыл бұрын
It's a generic type not an object.
@Iwillownyouandbehappy
@Iwillownyouandbehappy 7 жыл бұрын
Fun Fun Functors.
@aleksd286
@aleksd286 4 жыл бұрын
Fun fun functor
@郑伟-r1t
@郑伟-r1t 9 жыл бұрын
magic
@stevemao1368
@stevemao1368 7 жыл бұрын
The definition is still not correct. A functor is any type (NOT object) with a map method. It must obey the law that preserves function composition while mapping. map() doesn't return anther functor but transforming elements in the same functor.
@alexminser1482
@alexminser1482 8 жыл бұрын
That hat though
@_the_one_1
@_the_one_1 6 жыл бұрын
Ok lets skip this video
@ctrlaltdebug
@ctrlaltdebug 8 жыл бұрын
Still wrong. A Functor is an object that acts as a function. web.stanford.edu/class/cs106l/course-reader/Ch13_Functors.pdf
@funfunfunction
@funfunfunction 8 жыл бұрын
+CtrlAlt Debug that article is talking about functor in the sense of function object in C++. That is not at all the same thing as what we are talking about here, but unfortunately they are using the same name.
Streams - FunFunFunction #13
15:53
Fun Fun Function
Рет қаралды 81 М.
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
PHP DERSLERİ - PDO PART 1 (PDO Bağlantısı Oluşturma)
10:35
Zamansız Eğitimler
Рет қаралды 9
var, let and const - What, why and how - ES6 JavaScript Features
19:19
Fun Fun Function
Рет қаралды 181 М.
Functional Programming - 22: Functor
19:21
Web Village Voyage
Рет қаралды 7 М.
Recursion - Part 7 of Functional Programming in JavaScript
15:44
Fun Fun Function
Рет қаралды 237 М.
What the Functor? | Functors in Scala | Rock the JVM
24:43
Rock the JVM
Рет қаралды 12 М.
The Dangers Of Promise.all()
6:15
Theo - t3․gg
Рет қаралды 69 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 679 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Brian Beckman: Don't fear the Monad
1:07:10
jasonofthel33t
Рет қаралды 402 М.