Created
March 6, 2020 22:07
-
-
Save pzp1997/b017ba23cc1224bb43716763425685b7 to your computer and use it in GitHub Desktop.
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
module Main exposing (main) | |
import Html | |
windows : List a -> List ( a, a ) | |
windows list = | |
case list of | |
x :: ((y :: _) as xs) -> | |
( x, y ) :: windows xs | |
_ -> | |
[] | |
windowsPalmer : List a -> List ( a, a ) | |
windowsPalmer list = | |
List.map2 | |
(\x y -> ( x, y )) | |
list | |
(List.drop 1 list) | |
windows2Palmer : (a -> a -> b) -> List a -> List b | |
windows2Palmer f list = | |
List.map2 f | |
list | |
(List.drop 1 list) | |
windows3Palmer : (a -> a -> a -> b) -> List a -> List b | |
windows3Palmer f list = | |
List.map3 f | |
list | |
(List.drop 1 list) | |
(List.drop 2 list) | |
windows4Palmer : (a -> a -> a -> a -> b) -> List a -> List b | |
windows4Palmer f list = | |
List.map4 f | |
list | |
(List.drop 1 list) | |
(List.drop 2 list) | |
(List.drop 3 list) | |
windows2PalmerAlt : (a -> a -> b) -> List a -> List b | |
windows2PalmerAlt f list = | |
case list of | |
_ :: xs -> | |
List.map2 f list xs | |
_ -> | |
[] | |
windows3PalmerAlt : (a -> a -> a -> b) -> List a -> List b | |
windows3PalmerAlt f list = | |
case list of | |
_ :: ((_ :: ys) as xs) -> | |
List.map3 f list xs ys | |
_ -> | |
[] | |
windows4PalmerAlt : (a -> a -> a -> a -> b) -> List a -> List b | |
windows4PalmerAlt f list = | |
case list of | |
_ :: ((_ :: ((_ :: zs) as ys)) as xs) -> | |
List.map4 f list xs ys zs | |
_ -> | |
[] | |
main = | |
let | |
allGood = | |
List.all | |
(\i -> | |
let | |
list = | |
List.range 1 i | |
in | |
always True (windowsPalmer list) | |
) | |
(List.range 100000 100001) | |
in | |
Html.text <| | |
if allGood then | |
"OK" | |
else | |
"Bad" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment