Skip to content

Instantly share code, notes, and snippets.

@BanksySan
Last active February 24, 2018 23:28
Show Gist options
  • Save BanksySan/15d8d8fb0be9c2093088a555a15d3d36 to your computer and use it in GitHub Desktop.
Save BanksySan/15d8d8fb0be9c2093088a555a15d3d36 to your computer and use it in GitHub Desktop.
Useful F# finctions
let splice index array =
match array with
| [] -> (array, [])
| array -> if array.Length < index then (array, []) else (array.[..index - 1], array.[index..])
let characters = seq {
// 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
for asciiCode = 0x61 to 0x7A do yield (char) asciiCode // [a-z]
// 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
for asciiCode = 0x41 to 0x5A do yield (char) asciiCode // [A-Z]
// '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
for asciiCode = 0x30 to 0x39 do yield (char) asciiCode // [0-9]
// '-'
yield '-'
}
//As literal list:
let characters = ['a';'b';'c';'d';'e';'f';'g';'h';'i';'j';'k';'l';'m';'n';'o';'p';'q';'r';'s';'t';'u';'v';'w';'x';'y';'z';'A';'B';'C';'D';'E';'F';'G';'H';'I';'J';'K';'L';'M';'N';'O';'P';'Q';'R';'S';'T';'U';'V';'W';'X';'Y';'Z';'0';'1';'2';'3';'4';'5';'6';'7';'8';'9';'-';]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment