Just this week, I decided to start learning Kotlin because I want to build a mobile app.
Everything was going great until I reached lambda functions.
Honestly, I can't wrap my head around either their purpose or their syntax. I find them incredibly confusing. Right now, they feel like something that was invented purely to confuse developers.
I know this might just be one of those topics where you suddenly have an "aha" moment and everything clicks, but so far, that moment hasn't come.
Did anyone else coming from older, more imperative languages struggle this much with lambdas? Any tips or mental models that helped you finally "get" them?
However, how do you inject logic INTO the middle of a function?
Say you have a function which can iterate over any list and given a condition do a filter. How do you inject the condition logic into that filter function?
In the C days you would use a function pointer for this. C++ introduced templating so you could do this regardless of type. Lambdas make the whole process more ergonomic, it's just declaring a one-shot function in place with some convenient syntax.
In rust instead of the full blown
fn filter_condition(val: ValType) -> bool { // logic }
I can declare a function in place with |val|{logic} - the lambda is just syntactic sugar to make your life easier.
Elo gains for engines tend to come from better evaluation, better pruning, and better search heuristics. That's not to say that longer search time or a stronger CPU doesn't help, it just doesn't magically make a weak engine into a strong engine.
But Gemini will put me in my place. Sometimes I ask my question to Gemini because I don’t trust ChatGPT’s affirmations.
Truthfully I just use both.
1. Glazes me 2. Lists a variety of assumptions (some can be useful / interesting)
Answers the question
At least this way I don't spend a day pursuing an idea the wrong way because ChatGPT never pointed out something obvious.
Also this calculation probably assumes no baseload power imported from the grid, where means such as wind and tidal power work year-round and help offset the need for batteries.
In a 100% renewable world we would not be extracting or refining oil. Natural gas (used by these turbines) is a byproduct of oil drilling. Were we not burning the oil, the natural gas might be too expensive alone.
Also, in a 100% renewable world we would (by definition) have enough generation all the time - (covered by batteries and good baseload sources) that turbine power was no longer required to cover peak loads.
If a CEO delivers a certain advantage (a profit multiplier) it's rational that a bidding war will ensue for that CEO until they are paid the entire apparent advantage of their pretense for the company. A similar effect happens for salespeople.
The key difference between free and real markets in this case is information and distortions of lobbying. That plus legal restrictions on the company. The CEO is incentivized to find ways around these issues to maximize their own pay.
These are valuable skills, though perhaps nowhere near as valuable as they end up being in a free market.
Use an encouraging tone. Adopt a skeptical, questioning approach. Call me on things which don't seem right. List possible assumptions I'm making if any.