|
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...
|
|
|
|
|
Ian Shlasko wrote: 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...
|
|
|
|
|
I've been using TortioseSVN for years and it's all I know, easy to use but quirky.
I went to retrieve a file a little while ago and noticed a months worth of work missing, simply vanished out of the repository. I do weekly off computer backups so I don't have a problem there but the last backup was, of course 6 days ago on the 5th and I've got the current working copy but everything in between is gone.
This is the last straw and I want to migrate to GIT but am dirt stupid about it can someone recommend a simple, easy to use GUI for windows.
Also any good references/links for beginners would be helpful.
Thanks
[edit]
Currently looking at GitHub for windows. Any thoughts?
[/edit]
New version: WinHeist Version 2.1.0
My goal in life is to have a psychiatric disorder named after me.
I'm currently unsupervised, I know it freaks me out too but the possibilities are endless.
|
|
|
|
|
I just use VS2013 - I am pretty happy about it. Most things can be done it it and for those advanced things there is always the command line.
|
|
|
|
|
The first thing I recommend is to look for some tutorials to git for svn users. There are quite a few on the net and you should read them. I was hard time svn user and in contrast to popular believes transition was not easy or intuitive
For the gui itself I have 2 for you to consider:
SourceTree[^] is probably the most eye-candy and quite simple to use.
Git Extensions[^] is ugly as hell but seem to offer more control of what you are doing. Also integrates quite good with VS (although VS has also native GIT client)
I'm still missing some features of svn but after few years of using git I don't look back even in my personal projects.
Good luck
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
If you really want a GUI then either use the VS integrated git (it is quite usable) or the GitHub client (yes, that one is good). But I highly recommend learning the command line. Really, there is nothing more fun and powerful. Also it is usually much faster than using the GUI (and I am talking about speed of interaction, not execution). For the command line I recommend PoshGit, which is a nice layer on top of git, perfectly integrated in the PowerShell.
|
|
|
|
|
|
Great combo. I use them myself.
As for the command line, I've just moved to Posh-Git, hosted in PowerShell. It's a lot friendlier being able to do so much more Windows stuff natively than Git Bash.
No object is so beautiful that, under certain conditions, it will not look ugly. - Oscar Wilde
|
|
|
|