Coping with Vim
1:20
9 ай бұрын
Counting Sort
3:48
Жыл бұрын
[c][explained] Destructive XOR
2:29
2 жыл бұрын
[c] Introduction to Linked Lists
3:54
[vim] The Normal Command
2:28
2 жыл бұрын
Getting Control on the Shell
3:25
2 жыл бұрын
[vim] Formatting JSON
1:25
3 жыл бұрын
[vim] Marks
2:27
3 жыл бұрын
[vim] Silly Comment Box
1:59
3 жыл бұрын
[vim] Copying Recent Files
4:19
3 жыл бұрын
[vim] The Block Mode
0:58
3 жыл бұрын
Tiny Channel Update
0:26
3 жыл бұрын
02 Vim
8:55
3 жыл бұрын
01 Vim
12:35
3 жыл бұрын
[vim] Macros
1:40
3 жыл бұрын
[vim] Navigation Across Lines
3:34
3 жыл бұрын
[css] Flex vs Grid
4:38
3 жыл бұрын
[bash][zsh] The Bang
3:30
3 жыл бұрын
[vim] Text Objects
2:40
3 жыл бұрын
Пікірлер
@chepeniv
@chepeniv 9 күн бұрын
oh qwewl. now i can wyte a funcsion that swots in bowth deqweeseen and inqweeseen owdoh
@yt-sh
@yt-sh 12 күн бұрын
I knew pure functions were useless but testing impure functions by making them purer is a good idea esp with all these examples
@dibbyo456
@dibbyo456 17 күн бұрын
Very easy to understand.
@bboiyt8071
@bboiyt8071 24 күн бұрын
Stack can be both ADT and Data structure based on the context..when defined in terms of its operation it is ADT and when we use arrays or linked list to create one its a data structure
@theteachr
@theteachr 24 күн бұрын
This isn’t as helpful a discussion, but I don’t agree. A stack does not care about the underlying data structure (abstract over it). When you use an array to implement a Stack, it’s an implementation of Stack - the ADT with an array - the data structure.
@ugouchendu581
@ugouchendu581 28 күн бұрын
THANK YOUU
@juniorrokudevelopertutoria3734
@juniorrokudevelopertutoria3734 Ай бұрын
nice explanation
@ZinWesam
@ZinWesam Ай бұрын
@MrSomethingdark
@MrSomethingdark Ай бұрын
why the algorithm let's those usually indians with awful english be the first results is beyond me. Those people usually just take scripts from the most popular Udemy courses and rehash them. This is some great work here and the contrast shows. Take note KZbin.
@trannusaran6164
@trannusaran6164 Ай бұрын
Gender: 0x0A
@feshii
@feshii 2 ай бұрын
very nice vid man, thanks a lot
@SapereAude1490
@SapereAude1490 2 ай бұрын
This is a fantastic explanation. I came across counting sort while trying to understand a spatial hash data structure.
@neovimdev
@neovimdev 2 ай бұрын
Ey nice video, whats the font you are using? Looks awesome
@theteachr
@theteachr 2 ай бұрын
One of the classics: Roboto Mono.
@soleboxy
@soleboxy 2 ай бұрын
once you have the 4 cell array filled with [2,5,7,8] why not simply use a for loop over it and fill each of the cells of the result with the color for i < <number in current cell>? meaning , for the cell with 2 you can fill the result array for any cell number under 2 with green for yello cell continue filling from the next index up to 5 not including, for the next up to 7 for the next up to 8.
@theteachr
@theteachr 2 ай бұрын
Good question! For simpler items (numbers), "filling" is trivial, where what you're suggesting is an efficient way to do things. But consider an array of complex items, where each item is a message object and we're interested in sorting them by their priority (a member on the object). The process of "filling" might not even be possible, or when it is, it will perform badly as you'd be making copies (allocations) of the complex objects. The method described in the video allows you to reuse items present in the original array.
@tonysofla
@tonysofla 3 ай бұрын
in Assembler you could take advantage of that Carry is set and then adc #0, so you don't have to branch on not-carry, just use it to add a 1. But in C, carry is hidden.
@achie159
@achie159 3 ай бұрын
I fucking hate css it’s to much information
@NoteNodex
@NoteNodex 3 ай бұрын
still good after 4 years
@II_Emilia_II
@II_Emilia_II 3 ай бұрын
This was a hundred times more easier to understand with colors instead of numbers
@Naruto_Uzumaki_
@Naruto_Uzumaki_ 4 ай бұрын
Thank you! That was very concise and straight to the point
@preoalex8298
@preoalex8298 4 ай бұрын
In C you should typedef your structs so that you dont write “struct” every time. typedef struct Node { void *data; Node *next; } Node; Node n = …;
@Codeccino
@Codeccino 4 ай бұрын
Great work. What is the application you used to create these graphics and animations
@theteachr
@theteachr 3 ай бұрын
theteachr.github.io
@ElaineParra
@ElaineParra 4 ай бұрын
Please keep adding videos about DS😊
@alibarznji2000
@alibarznji2000 5 ай бұрын
I'm not a low-level developer and neither do I understand anything about Assembly. But isn't the compiler smart enough to optimize your branch code in Assembly that it doesn't make a difference performance wise?
@dilligentstreetcat
@dilligentstreetcat 4 ай бұрын
100%, sometimes even can cause the compiler to produce less performant assembly. But he literally says pretty much this in the description.
@yuribuzynnik1312
@yuribuzynnik1312 5 ай бұрын
Thank you for explanation!
@v0id_d3m0n
@v0id_d3m0n 5 ай бұрын
Brilliant video with great examples. I also love how clean the code graphics look😋
@v0id_d3m0n
@v0id_d3m0n 5 ай бұрын
5:36 iconic line
@abdullah5802
@abdullah5802 5 ай бұрын
Vaas Montenegro*
@theteachr
@theteachr 5 ай бұрын
5:56 Correction: No! Not all pure functions are idempotent. A function need not be idempotent to be pure.
@roelhemerik5715
@roelhemerik5715 5 ай бұрын
I don’t get why all impure function are idempotent bij nature… Take f x = x + 1. Then f(1) != f(f(1)). What makes f impure?
@theteachr
@theteachr 5 ай бұрын
f is not impure, but you did point out the incorrect thing I said. I meant to say, "pure functions are idempotent." But that's wrong. Pure functions need not be idempotent. Thanks for bringing this up.
@lah30303
@lah30303 5 ай бұрын
If a function mutates a reference passed to it, isn't it still simply testable by calling it on a copy of a value and comparing the mutated 'side effect' with the original value? You could just as easily annotate that the mutation only occurs on the data referenced and effectively treat it as a return value for the sake of testing. It seems to me like returning data is just as much of a "side effect" as mutating a clearly defined segment of data.
@theteachr
@theteachr 5 ай бұрын
It's just a lot more to think about when you find such a reference being passed around with mutation. You'd have to keep a look out for where it's being passed and whether it gets mutated in that place. Values are much easier to reason about. They just can't change. No matter where or how you pass them. Any change is reflected by a new value. A smart compiler can see when the old value is not used after and just do an in place mutation.
@MrLuigiBean1
@MrLuigiBean1 5 ай бұрын
Your videos look so clean! What do you use/do to make them look as good as they do?
@theteachr
@theteachr 5 ай бұрын
theteachr.github.io
@user-tk2jy8xr8b
@user-tk2jy8xr8b 5 ай бұрын
Essentially, in a simple case when equality is defined over the argument type, a function is pure if it can be replaced by an associative array (possibly of an infinite size). Also a function is side-effect free when it's impossible to tell `let b = (f a, f a) in b` from `let b = f a in (b, b)` both executed eagerly.
@theteachr
@theteachr 5 ай бұрын
This is getting into referential transparency.
@user-tk2jy8xr8b
@user-tk2jy8xr8b 5 ай бұрын
@@theteachr yes, it also touches functional extensionality
@dkd0m23
@dkd0m23 5 ай бұрын
i couldn't help but laugh my ass off when you suggested running the greet function in the morning to test if it says good morning 😆
@shadow-ht5gk
@shadow-ht5gk 5 ай бұрын
Functional programmers in shambles after seeing the thumbnail
@theteachr
@theteachr 5 ай бұрын
I think they’re well aware of it.
@mage3690
@mage3690 5 ай бұрын
grep is a pure function.
@theteachr
@theteachr 5 ай бұрын
Everything is pure in an immutable context.
@captainswing4040
@captainswing4040 5 ай бұрын
about that quote in the beginning imagine you are practicing any skill in other words, doing something over and over and expecting to improve will you call that insanity?
@theteachr
@theteachr 5 ай бұрын
No, you’re expecting the same result: Improvement. More technically, you wouldn’t be doing the same thing either. Every time you do it again, your previous doing would have changed you.
@captainswing4040
@captainswing4040 5 ай бұрын
@@theteachr i see your point but still there are many things where our effort is not the only factor and trying again and again is not insanity i do not completely agree with that quote
@DaKeypunchAr
@DaKeypunchAr 5 ай бұрын
The best thing i got to know from the video is that "Burgers are Sandwiches"
@idiomaxiom
@idiomaxiom 5 ай бұрын
I love that FP don't think we can determine that the sun will come up tomorrow. Times isn't that scary lol
@ekr990011
@ekr990011 5 ай бұрын
The problem of this is every function is impure. Any boolean check any math operation any string manipulation or check. Are all functions imported implicitly by your function. This logical inconsistency has always made fp feel a lot like a shady salesman talking about ideals while they are technically impossible to do, ever. I think you did a good job of stating a good middle ground. Fp still has this issue of no true scotsman while all pretending it is possible and the way to do things.
@shadow-ht5gk
@shadow-ht5gk 5 ай бұрын
Fair point, I guess to make it truly pure it needs to pass definitions for any operators/functions that are used in the function as arguments.
@theteachr
@theteachr 5 ай бұрын
I like the take. But what matters is whether the properties are held. Checking a bool maybe impure, but does it ever behave non deterministically? If it does, we have a more serious problem. A function when executed by a run time might (more that it will) have a side effect but can still be pure given that that side effect is not affecting your program's behavior. As long as the properties are held, you're objectively in a better position to reason about your program. And that's what FP tries to maximize.
@theteachr
@theteachr 5 ай бұрын
@@shadow-ht5gk A pure function can call another pure function without losing purity. It will still be deterministic and doing no side effects. You can chain a bunch of pure functions into another pure function when you see the same chain of calls being made in more than a few places.
@NJ-wb1cz
@NJ-wb1cz 4 ай бұрын
​@@theteachr the properties aren't held, they aren't real. Your function tries to allocate a string and runs out of memory and needs to somehow stat alive, of course that's impure. Your thread does a calculation and gets shut down in the middle of it and needs to restart and continue correctly - if you actually believe it's pure it should be impossible. In reality these are also possibilities that you are faced with among many others. This purity business is more like something we play with and imagine to improve our code and that's fine because it can help, but we shouldn't forget that all of that is fake and made up by us to help us think in a particular way about things as opposed to describing actual things.
@re.liable
@re.liable 5 ай бұрын
I gained valuable insights from this video. I've been using the "sandwich pattern" a lot but didn't know it can be called that way. Also more recently I'm having issues about what to name and where to place those "filling" pure functions. I tend to place them in utils even when they're really only used for a specific place lol Also I guess the sandwich pattern can be hard to apply to e.g. DB calls when you can integrate a lot of the filling into the query, e.g. sorting, filtering, transformations
@theteachr
@theteachr 5 ай бұрын
Isn’t everything a utility? Shouldn’t they all go in utils? Utils is a smell. The filling pure functions should have a name and place inside the core. All side effect-y things can go into an IO namespace. From what I read, you are giving less importance to the filling.
@sunofabeach9424
@sunofabeach9424 5 ай бұрын
if only you pure function people have put so much effort into sync/async functions...
@theteachr
@theteachr 5 ай бұрын
Because doing so would make them impure.
@NJ-wb1cz
@NJ-wb1cz 4 ай бұрын
Async is pretty much solved by having virtual threads that eliminate the need for red/blue functions and disjointed mutually incompatible code. It's only a matter of having a GC that makes this possible and a language that supports them
@sunofabeach9424
@sunofabeach9424 4 ай бұрын
@@NJ-wb1cz functional programming is exactly the kind of a thing that would make async functions achievable without coloring or even runtime
@NJ-wb1cz
@NJ-wb1cz 4 ай бұрын
@@sunofabeach9424 I'm not talking about ifs or woulds, I'm talking about java that already has async without color functions or async/await
@NJ-wb1cz
@NJ-wb1cz 4 ай бұрын
@@sunofabeach9424 can you provide an example where this is implemented?
@TheDiveO
@TheDiveO 5 ай бұрын
Also attributed to A. Einstein: to produce yet another video about pure functions and expecting a different outcome...
@shrek95372q
@shrek95372q 5 ай бұрын
are you pure programmer or you use js on side?
@PixelOutlaw
@PixelOutlaw 5 ай бұрын
You need to name your function such that it's immediately obvious when something mutates and you need to be very consistent with that. Scheme programmers often append ! to their function names which mutate state. Adding commentary is another thing that lazy programmers don't do which makes code harder to reason about.
@theteachr
@theteachr 5 ай бұрын
Even Ruby does !
@ImperiumLibertas
@ImperiumLibertas 5 ай бұрын
If you have to comment your code to be understood then it is almost always poorly written. Using named variables and functions and defensive programming goes a long way in making code more readable.
@PixelOutlaw
@PixelOutlaw 5 ай бұрын
@@ImperiumLibertas On occasion you need the "why" of what you're doing. Good comments add context, not restate the what.
@gljames24
@gljames24 5 ай бұрын
1 That is not how a definition works 2 Albert Einstein never said that
@hadrian2801
@hadrian2801 5 ай бұрын
Bro really quoted vaas and expected me not to notice
@monad_tcp
@monad_tcp 5 ай бұрын
There are no impure functions, those are called procedures. its all the fault of the languages derived from C
@jettrom609
@jettrom609 5 ай бұрын
also, you could still have an impure function, as long as it is indeterministic.
@Duoan-yr5pd
@Duoan-yr5pd 5 ай бұрын
Thank you very much ! You saved my code program. Hope you have a nice day
@simplykyle
@simplykyle 5 ай бұрын
How do you make these videos! They seem wonderful! Is it some powerpoint morph magics? Or is it motion canvas
@theteachr
@theteachr 5 ай бұрын
Keynote Magic Move >>> PowerPoint Morph
@4ngelf
@4ngelf 5 ай бұрын
I was left with some doubt. Is it possible to write, for example, a GUI library, a memory allocator, or a caching system in a pure functional way? Or is it that there exists software that can only be written as mostly impure?
@theteachr
@theteachr 5 ай бұрын
Someone *has* to do the side effects. Even if you're writing a memory allocator, you can express its behaviour in a pure functional way. The act of doing / inserting the side effects will be the responsibility of runtime / compiler. The goal is to maximise describing the what over how.
@grokitall
@grokitall 5 ай бұрын
basically, you write as much as possible to be pure, and then a thin veneer of small and simple impure functions. this also has the benefit that it makes changing the ui code easy. so you develop the pure functions in the library, add thin impure functions at the edge, then you can turn it into a cli tool to exercise the parameters, have a separate thin web ui for headless use, and a gui for desktop use. this is why people who do ci and tdd have implausibly high code coverage, because it is mainly pure functions.
@Daniel_Zhu_a6f
@Daniel_Zhu_a6f 5 ай бұрын
what i've discovered recently for myself are pure-impure functions. they have a pure function at the core, but have optional /flag arguments that make them read data from files or save results to files or log loop progress, etc. this makes function composable and testable while keeping the brevity and locality of behavior that we like about effectful functions. eg the code at 2:20 could be rewritten to accept time as an optional parameter. then the function would be pure if time is passed and would infer system time if null pointer is passed in place of time.
@theteachr
@theteachr 5 ай бұрын
While I don't completely dismiss this idea, every flag results in a branch, doubling the number of valid paths, which would bother me. I can understand if it's small piece of code, but I would still prefer the decorator. Pure function is completely pure and the impure counterpart just wraps over it with side effects and / or reading external sources.
@Daniel_Zhu_a6f
@Daniel_Zhu_a6f 5 ай бұрын
@@theteachr i'm not sure what you mean by a "decorator". if it's just a function that provides additional pre/post processing of arguments/return values of a target function, then i don't see much difference between these approaches. if it's something like python decorators or "design patterns"TM decorators, then i don't like them. i find them very cumbersome and not suitable for most tasks. if it's something along the lines of lisp-style macros, or some other code generation technique, then it's a total overkill for 99% of tasks.
@mskiptr
@mskiptr 5 ай бұрын
Hmm, this idea might be formalizable into some kind of polymorphism around the effect system. Oh wait… Isn't this what Idris does already? Also, free monads are a very similar concept.
@grokitall
@grokitall 5 ай бұрын
or you can just wrap your impure function around the pure one as shown in the video. this is better, as you don't muck up your api with the optional parameter. also because the pure function is testable, and the impure function is almost trivial because it is just thin glue around the pure function, so it is near trivial. it makes ci and tdd easy.