-
-
Save Judgy53/b754110949d949acc1ae48fed566a306 to your computer and use it in GitHub Desktop.
ch2 plan url encode idea
This file contains 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
nodesToBuild : G.Graph -> Set G.NodeId -> Maybe String | |
nodesToBuild graph = | |
Set.toList | |
>> List.sort | |
>> splitforAlphabet [] | |
>> alphabetize | |
>> String.join "&" | |
>> (\s -> | |
if s == "" then | |
Nothing | |
else | |
Just s | |
) | |
splitforAlphabet : List (List G.NodeId) -> List G.NodeId -> List (List G.NodeId) | |
splitforAlphabet globalList currentList = | |
let | |
( stList, bgeList ) = | |
List.Extra.break ((<=) 74) currentList | |
shiftedBgeList = | |
List.map (\i -> i - 73) bgeList | |
in | |
if not (List.isEmpty shiftedBgeList) then | |
splitforAlphabet (globalList ++ [ stList ]) shiftedBgeList | |
else | |
globalList ++ [ stList ] | |
alphabetize : List (List G.NodeId) -> List String | |
alphabetize splittedList = | |
let | |
alphabet = | |
String.toList "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*'()," | |
result = | |
List.map | |
(\l -> | |
String.fromList <| | |
List.map | |
(\i -> | |
List.Extra.getAt (i - 1) alphabet | |
|> Maybe.withDefault '1' | |
) | |
l | |
) | |
splittedList | |
in | |
result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment