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) |
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
| 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
| 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
| 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
| 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
| int pixelsize = 4; | |
| int gridsize = pixelsize * 7 + 5; | |
| Player player; | |
| ArrayList enemies = new ArrayList(); | |
| ArrayList bullets = new ArrayList(); | |
| int direction = 1; | |
| boolean incy = false; | |
| int score = 0; | |
| PFont f; |
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
| from review import KNNPoint, predict | |
| dataset = [ | |
| KNNPoint([842.0, 2.2, 7.0, 2.0, 2549.0], "medium cost"), | |
| KNNPoint([1021.0, 0.5, 53.0, 3.0, 2631.0], "high cost"), | |
| KNNPoint([563.0, 0.5, 41.0, 5.0, 2603.0], "high cost"), | |
| KNNPoint([615.0, 2.5, 10.0, 6.0, 2769.0], "high cost"), | |
| KNNPoint([1821.0, 1.2, 44.0, 2.0, 1411.0], "medium cost"), | |
| KNNPoint([1859.0, 0.5, 22.0, 1.0, 1067.0], "medium cost"), | |
| KNNPoint([1821.0, 1.7, 10.0, 8.0, 3220.0], "very high cost"), |
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
| import requests | |
| from bs4 import BeautifulSoup | |
| import json | |
| import unicodedata | |
| def normalize(text): | |
| nfkd_form = unicodedata.normalize('NFKD', text) | |
| only_ascii = nfkd_form.encode('ASCII', 'ignore') | |
| return only_ascii.lower().decode() |
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
| import grequests | |
| import json | |
| import unicodedata | |
| from bs4 import BeautifulSoup | |
| def download(urls): | |
| def catcher(req, ex): | |
| print(ex) | |
| reqs = map(grequests.get, urls) |
OlderNewer