-
-
Save rtfeldman/c3ec88e469363651e4ee462599ef2083 to your computer and use it in GitHub Desktop.
Field Generation Algorithm for Evan
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
{ | |
"version": "1.0.0", | |
"summary": "Tell the world about your project!", | |
"repository": "https://github.com/user/project.git", | |
"license": "BSD3", | |
"source-directories": [ | |
"." | |
], | |
"exposed-modules": [], | |
"dependencies": { | |
"elm-lang/core": "5.1.1 <= v < 5.1.1", | |
"elm-lang/html": "2.0.0 <= v < 2.0.0" | |
}, | |
"elm-version": "0.18.0 <= v < 0.19.0" | |
} |
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
<html> | |
<head> | |
<style> | |
html { | |
background: #F7F7F7; | |
font-family: monospace; | |
} | |
</style> | |
</head> | |
<body> | |
<script> | |
var app = Elm.Main.fullscreen() | |
</script> | |
</body> | |
</html> |
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
module Main exposing (..) | |
import Html exposing (pre, text, Html) | |
main : Html a | |
main = | |
-- List.range 0 200 | |
-- List.range 3364 3388 | |
-- List.range 216358 216375 | |
List.range 0 200 | |
|> List.map (\num -> ((String.padRight 7 ' ' (toString num ++ ") ")) ++ toFieldName num)) | |
|> String.join "\n" | |
|> text | |
|> List.singleton | |
|> pre [] | |
toFieldName : Int -> String | |
toFieldName num = | |
if num < firstCharOptions then | |
toFieldNameHelp num | |
else | |
-- Skip 0-9, _, and $ in the single-char case | |
toFieldNameHelp (num + secondCharOptions - firstCharOptions) | |
toFieldNameHelp : Int -> String | |
toFieldNameHelp num = | |
if num < 0 then | |
"" | |
else if num >= 64 then | |
toFieldName | |
(floor | |
(toFloat num / toFloat 64) | |
- 1 | |
) | |
++ toFieldNameHelp (num % 64) | |
else | |
case num of | |
0 -> | |
"a" | |
1 -> | |
"b" | |
2 -> | |
"c" | |
3 -> | |
"d" | |
4 -> | |
"e" | |
5 -> | |
"f" | |
6 -> | |
"g" | |
7 -> | |
"h" | |
8 -> | |
"i" | |
9 -> | |
"j" | |
10 -> | |
"k" | |
11 -> | |
"l" | |
12 -> | |
"m" | |
13 -> | |
"n" | |
14 -> | |
"o" | |
15 -> | |
"p" | |
16 -> | |
"q" | |
17 -> | |
"r" | |
18 -> | |
"s" | |
19 -> | |
"t" | |
20 -> | |
"u" | |
21 -> | |
"v" | |
22 -> | |
"w" | |
23 -> | |
"x" | |
24 -> | |
"y" | |
25 -> | |
"z" | |
62 -> | |
"_" | |
63 -> | |
"$" | |
_ -> | |
if num > 51 then | |
toString ((num % 51) - 1) | |
else | |
(num - 26) | |
|> toFieldNameHelp | |
|> String.toUpper | |
firstCharOptions : Int | |
firstCharOptions = | |
52 | |
secondCharOptions : Int | |
secondCharOptions = | |
64 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment