|
Agreed. I write some training on occasion and the hard part is not to get caught up on the nuances of the subject matter and focus on getting the point across where the person can be functional. Also when you're training someone who has no exposure to your subject matter it can be extremely hard to get the person to relate. As my old English teacher said, "Make the abstract concrete."
|
|
|
|
|
newton.saber wrote: Do you like TED Talks?
I liked TED the movie.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
So I'm reading this book about Haskell[^] and the author creates a function that converts an int to a lower case letter. The function is called 'int2let'. If I did that in any of the major languages today (and probably a few non-major languages as well) I'd probably be lynched by an angry mob of (non-Haskell) programmers.
Well, maybe that's why Haskell isn't that popular yet...
Other than the function naming Haskell is pretty awesome though. I'm not sure if I'll ever be able to use it in a real project though.
For the enthusiasts
One of the things that amazed me is currying functions.
--function definitions
add x y = x + y
incr = add 1
--usage
add 5 5 -- result 10 (duh)
incr 5 -- result 6 How cool is that? add x actually returns a function that expects y and thus incr returns that function.
Can be practical when working with lambda's or partial application (like in the example).
|
|
|
|
|
Haskell also has a function to convert human hair into fingernails. It's called Hair2Fingernails. It's almost as valuable as the int2let. int2let is amazing and no one should question that ever.
|
|
|
|
|
for a good laugh!
|
|
|
|
|
Are you mocking the mighty Haskell? Well, I guess it deserved it
|
|
|
|
|
Pretty standard for a functional language..
If you like that, pointless point free style will blow your mind.
|
|
|
|
|
Nit-picking corner:
Your code example shows partial function application, not currying. They're related, but not quite the same thing.
Currying and partial application is easy* in C#, once you've got your head around the concept:
Currying and Partial Function Application - MSDN Blogs[^]
Currying vs partial function application - Jon Skeet's blog[^]
public static class FunctionalExtensions
{
public static Func<A, Func<B, R>> Curry<A, B, R>(this Func<A, B, R> f)
{
return a => b => f(a, b);
}
public static Func<B, R> Apply<A, B, R>(this Func<A, B, R> f, A a)
{
return b => f(a, b);
}
}
Func<int, int, int> add = (a, b) => a + b;
Func<int, int> incr = add.Apply(1);
Func<int, Func<int, int>> curriedAdd = add.Curry();
There's a bit more ceremony, as C# isn't as good at inferring argument types as most functional languages, but it's still usable.
* For certain values of "easy".
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: Nit-picking corner:
This is exactly as I would expect from a functional programmer.
Yes, I'm kidding.
But we're all thinking it about functional programmers. Admit it.
|
|
|
|
|
Nobody calls me a "functional programmer" and gets away with it!
Except that one guy who called me a "functional programmer" and then ran off. He got away with it.
But most people who call me a "functional programmer" don't get away with it.
Well, actually, that guy who got away with it was the only one who ever called me a "functional programmer".
After today, only half the people who ever called me a "functional programmer" will have gotten away with it.
(Bonus points if you can identify the reference!)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: (Bonus points if you can identify the reference!) Sounds like something I heard back in Quahog...
|
|
|
|
|
To quote Weenie and the Butt, "We Have a Weiner"!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Would you prefer to be known as a dysfunctional programmer?
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Cool, thanks
Just read and practiced list comprehensions. A bit odd to call that 'comprehension'
|
|
|
|
|
Well?
Don't just leave us hanging, like that!
What letter is 42?!?
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Not sure I like the currying functions.
A bit spicy for me - I'll get my coat
Life is like a s**t sandwich; the more bread you have, the less s**t you eat.
|
|
|
|
|
My current (WPF) project requires me to generate "score cards" on the screen, as well as be able to save them as JPG files. Saving them one at a time after being displayed worked just fine, but saving them all at the same time (without being displayed first) was a pain. It seems that the databinding wasn't happening fast enough, resulting in large swaths of empty space in each resulting image. After three days of trying to figure it out, I finally came up with a solution - iterate through the various data bound controls and call BindingExpression.UpdateTarget on each one.
After doing that (and having fixed the problem), I think the actual cause is the way I'm initializing each user control on the score card. In short, I think I shot myself in the foot. At this point, I don't want to see if I'm right because quite frankly, I'm tired of dickin' with it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
John Simmons / outlaw programmer wrote: I think I shot myself in the foot No wonder, from what I gather you keep an awful lot of guns around...
John Simmons / outlaw programmer wrote: I'm tired of dickin' with it Best not shoot yourself there too!
|
|
|
|
|
Web APIs are what I focus on these days. I gave up WPF last year, and I haven't looked back. I actually can't remember working with anyone that was elated to work on WPF projects. I'm sure there were some, but I didn't know them.
|
|
|
|
|
Bah, I like WPF... The web just complicates everything.
Seriously, I've been messing around with MVC4/Razor, and while it's pretty neat, it takes so much more work to do something that takes me five minutes in WPF.
|
|
|
|
|
Ian Shlasko wrote: do something that takes me five minutes in WPF And only one minute in WinForms!
|
|
|
|
|
I tried knocking together a quick and dirty in winforms the other day, they have changed the dataset/datatable functionality since I last used it and I found my self on Google looking for the syntax changes, chucked it out and built the bloody thing in WPF without MVVM, straight code behind.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Agreed.
I constantly hear about how "Windows apps are dead", and I say nonsense. WPF is and will continue to be a viable development platform.
It's DAR more easier than web development.
If it's not broken, fix it until it is
|
|
|
|
|
If you're writing to files, I wouldn't pull straight from a GUI control... Not what they're designed for.
A while back, I wrote a quick tool at home to generate a deck of custom playing cards (Uploaded the images to one of those print-on-demand services to get them as actual cards)... Trying to remember exactly how I did it, but I wasn't putting anything on the screen.
Basically, don't consider the screen an input... Just an output. You should be able to create a XAML template, apply it to a... damn, what was that class name... I think I hooked a VisualBrush up to a RenderTargetBitmap... Bleh, been too long... Can't remember, and don't have the code nearby...
|
|
|
|