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
| def none_slice_gabriel(lst, start, stop): | |
| i = start | |
| while i < 0 and i < stop: | |
| yield None | |
| i += 1 | |
| while i < len(lst) and i < stop: | |
| yield lst[i] | |
| i += 1 |
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
| Expr0 = Ws expr:(Appl / Expr1) Ws { | |
| return expr | |
| } | |
| Expr1 = expr:(Func / Name / Expr0Parenthesis) { | |
| return expr | |
| } | |
| Expr0Parenthesis = '(' expr:Expr0 ')' { | |
| return expr |
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 chanceToMutate = 5 | |
| let possibleChars = Array.append [|'A'..'Z'|] [|' '|] | |
| let random = new System.Random() | |
| let randomChar () = | |
| let index = random.Next(Array.length possibleChars) | |
| Array.item index possibleChars |
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 transposeColumn matrix index = | |
| seq { for row in matrix -> Seq.item index row } | |
| let transposeMatrix matrix = | |
| matrix | |
| |> Seq.mapi (fun index _ -> transposeColumn matrix index) | |
| let multiplyRows row1 row2 = | |
| Seq.zip row1 row2 | |
| |> Seq.map (fun (a, b) -> a * b) |
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
| class Graph(object): | |
| def __init__(self): | |
| self.g = {} | |
| def add(self, vertex1, vertex2, weight): | |
| if vertex1 not in self.g: | |
| self.g[vertex1] = {} | |
| if vertex2 not in self.g: | |
| self.g[vertex2] = {} |
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
| type FiniteAutomaton<'a> = { | |
| InitialState: string | |
| FinalStates: Set<string> | |
| Transitions: Map<string * char, 'a> | |
| } | |
| type DeterministicFiniteAutomaton = FiniteAutomaton<string> | |
| type NondeterministicFiniteAutomaton = FiniteAutomaton<string List> | |
| let private nextState symbol state fa = | |
| fa.Transitions |> Map.tryFind (state, symbol) |
NewerOlder