This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import functools | |
| array = [ 1 , 2, 3, 4] | |
| soma = functools.reduce(lambda primeiro_numero,segundo_numero : primeiro_numero + segundo_numero, array) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| UpsideDown<int> elevenPower = 100.PortalToUpsideDown(); | |
| UpsideDown<int> elevenIncreasedPower = | |
| UpsideDown<int>.Map( | |
| elevenPower, | |
| power => power * 10); | |
| UpsideDown<int> elevenIncreasedPower2 = | |
| elevenPower.Map(power => power * 10); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let elevenPower = 100 |> UpsideDown.portalTo | |
| let elevenIncreasedPower = | |
| elevenPower | |
| |> UpsideDown.map (fun power -> power * 10) | |
| let elevenIncreasedPower2 elevenPower = | |
| (fun power -> power * 10) <!> elevenPower |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let (<!>) = map |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static UpsideDown<TResult> Map<T, TResult>( | |
| this UpsideDown<T> value, | |
| Func<T, TResult> projection) | |
| => UpsideDown<T>.Map(value, projection); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static UpsideDown<TResult> Apply<T, TResult>( | |
| this UpsideDown<T> value, | |
| UpsideDown<Func<T, TResult>> upsideDownFunction) | |
| => UpsideDown<T>.Apply(value, upsideDownFunction); | |
| //Usage | |
| Func<string, string> messageWithLight = message => | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static UpsideDown<TResult> Map<TResult>( | |
| UpsideDown<T> upsideDownValue, | |
| Func<T, TResult> normalFunction) | |
| => Apply(upsideDownValue, normalFunction.PortalToUpsideDown()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let map normalFunction upsideDownValue = | |
| (normalFunction |> portalTo) | |
| <*> upsideDownValue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let map1 normalFunction upsideDownValue = | |
| upsideDownValue | |
| |> portalFrom | |
| |> normalFunction | |
| |> portalTo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static UpsideDown<TResult> Map1<TResult>( | |
| UpsideDown<T> upsideDownValue, | |
| Func<T, TResult> normalFunction) | |
| { | |
| var normalValue = upsideDownValue.PortalFromUpsideDown(); | |
| var normalResult = normalFunction(normalValue); | |
| return normalResult.PortalToUpsideDown(); | |
| } |
NewerOlder