Skip to main content
11 events
when toggle format what by license comment
Mar 27, 2017 at 14:54 audit First posts
Mar 27, 2017 at 14:54
Mar 22, 2017 at 14:01 comment added jpaugh @immibis Yes, the Compose function is really only useful if you need to delay the execution of GetRate for some reason, such as if you want to pass Compose(FormatRate, GetRate) to a function which provides a rate of its own choosing, e.g. to apply it to every element in a list.
Mar 22, 2017 at 13:38 comment added Luaan @rushinge This kind of composition works on the typical FP function which always has a single argument (additional arguments are really functions of their own, think of it like Func<Func<A, B>, C>); this means that you only need one Compose function that works for any function. However, you can work with C# functions well enough just using closures - instead of passing Func<rateKey, rateType>, you onlry really need Func<rateType>, and when passing the func, you build it like () => GetRate(rateKey). The point is that you don't expose the arguments the target function doesn't care about.
S Mar 21, 2017 at 20:29 history suggested carson CC BY-SA 3.0
Paramter names
Mar 21, 2017 at 19:47 vote accept NightWatchman
Mar 21, 2017 at 19:44 comment added NightWatchman I think this is what I'm trying to do here, and I've tried this Compose function before but it seems that I rarely get to use it because my 2nd function often needs more than one parameter. Perhaps I need to do this in combination with closures for configured functions as mentioned by @thomas-junk
Mar 21, 2017 at 17:08 review Suggested edits
S Mar 21, 2017 at 20:29
Mar 21, 2017 at 13:41 comment added Carles @immibis I guess the idea is that he'll be able to use GetFormattedRate directly from now on.
Mar 21, 2017 at 9:35 history edited Caleth CC BY-SA 3.0
Matching types
Mar 21, 2017 at 8:24 comment added Stack Exchange Broke The Law Do repeat yourself if avoiding repeating yourself makes the code worse. Such as if you always write those two lines instead of FormatRate(GetRate(rateKey)).
Mar 20, 2017 at 23:29 history answered Jack CC BY-SA 3.0