functional-programming

F# VS2019 Windows Forms

喜欢而已 提交于 2020-08-26 08:43:10
问题 I'm learning F# and I'm just trying to build Animate a pendulum program. Here's the code: https://rosettacode.org/wiki/Animate_a_pendulum#F.23 As far as I understand, VS 2019 doesn't support WinForms in F# (maybe, I'm wrong), so I have error messages, trying to copy/paste that code: What should I do? Thanks a lot ! 回答1: If you're looking to use Winforms on .NET core, you'll need to do the following in your project: Open the project file (double-click on the node in Visual Studio) Change the

Unifying Types in Haskell

自古美人都是妖i 提交于 2020-08-24 10:25:57
问题 I'm kind of stuck with an assignement concerning my exams. I want to find out the types of those two functions by applying the unifying algorithm by hand: map map (\x -> x >>= (\y -> y)) Could someone point me to the right direction? The only ressource I could find until now was the wikipedia entry which is not really aiding me because of the high level of abstraction. Greetings and thank you. 回答1: Let's just do the first. map :: (a -> b) -> [a] -> [b] Now we can write it again with two

Unifying Types in Haskell

末鹿安然 提交于 2020-08-24 10:22:08
问题 I'm kind of stuck with an assignement concerning my exams. I want to find out the types of those two functions by applying the unifying algorithm by hand: map map (\x -> x >>= (\y -> y)) Could someone point me to the right direction? The only ressource I could find until now was the wikipedia entry which is not really aiding me because of the high level of abstraction. Greetings and thank you. 回答1: Let's just do the first. map :: (a -> b) -> [a] -> [b] Now we can write it again with two

Unifying Types in Haskell

你离开我真会死。 提交于 2020-08-24 10:21:50
问题 I'm kind of stuck with an assignement concerning my exams. I want to find out the types of those two functions by applying the unifying algorithm by hand: map map (\x -> x >>= (\y -> y)) Could someone point me to the right direction? The only ressource I could find until now was the wikipedia entry which is not really aiding me because of the high level of abstraction. Greetings and thank you. 回答1: Let's just do the first. map :: (a -> b) -> [a] -> [b] Now we can write it again with two

Generic BiFunction that accepts generic wildcard

徘徊边缘 提交于 2020-08-24 04:22:06
问题 I have Enum and want to have a generic function that could accept any class that implements a maker interface. public interface IComponentDataExporter { // Marker Interface } public class ComponentsDataExporter implements IComponentDataExporter { public ComponentTeaser populateFeatured(ComponentTeaserConfiguration componentConfig) { return null; } } public class BussinessComponentsDataExporter implements IComponentDataExporter { // methods } public enum ComponentTypeEnum { FEATURED

Can Nullable be used as a functor in C#?

|▌冷眼眸甩不掉的悲伤 提交于 2020-08-22 08:32:33
问题 Consider the following code in C#. public int Foo(int a) { // ... } // in some other method int? x = 0; x = Foo(x); The last line will return a compilation error cannot convert from 'int?' to 'int' which is fair enough. However, for example in Haskell there is Maybe which is a counterpart to Nullable in C#. Since Maybe is a Functor I would be able to apply Foo to x using fmap . Does C# have a similar mechanism? 回答1: We can implement such functionality ourselves: public static class FuncUtils

Can Nullable be used as a functor in C#?

荒凉一梦 提交于 2020-08-22 08:32:10
问题 Consider the following code in C#. public int Foo(int a) { // ... } // in some other method int? x = 0; x = Foo(x); The last line will return a compilation error cannot convert from 'int?' to 'int' which is fair enough. However, for example in Haskell there is Maybe which is a counterpart to Nullable in C#. Since Maybe is a Functor I would be able to apply Foo to x using fmap . Does C# have a similar mechanism? 回答1: We can implement such functionality ourselves: public static class FuncUtils