- Protocol
- One JSON Dictionary transmitted as a string through ws or wss
- All Packets
- Fields
- "PacketType" - string
- Describes what type of packet this is
- "PacketID" - string
- Uniquely identifies the string transmitted
- "ProtocolVersion" - string
- "PacketType" - string
- Fields
- Identifies the current version of the protocol being used
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
(* | |
If you want, you can replace all | |
+? | |
with | |
+ | |
and this will still work. | |
It's just that the default (+) for `int` will be shadowed after the | |
let Open Num in | |
line | |
*) |
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
def fib(n): | |
a, b = 0, 1 | |
for _ in range(n): | |
a, b = b, a + b | |
return a | |
# fib n = go 0 1 n | |
# where go a _ 0 = a | |
# go a b n = go b (a + b) (n - 1) |
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
hailstone :: [[Int]] | |
hailstone = [] : [1] : map (\n -> let n' = collatz n in n : (hailstone !! n')) [2..] | |
collatz n = if even then half else 3 * n + 1 | |
where | |
(half, r) = n `quotRem` 2 | |
even = r == 0 | |
{- GHCI output, _ means that part hasn't been evaluated yet | |
Prelude> hailstone !! 3 |
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
# Forgets results in between calls | |
# Also, it is nowhere close to as efficient as the Haskell version | |
# i.e. I think this is exponential in time | |
def fibs_gen(): | |
yield 0 | |
yield 1 | |
fib = fibs_gen() | |
fib_tail = fibs_gen() |
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
from typing import List | |
from pyrsistent import pvector | |
from pyrsistent.typing import PVector | |
def benchmark_jump(n: int): | |
string = 'xx.' * n | |
for i in range(0, n, 3): | |
string = jump(string, i, 1) |
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
def Zero(zero_val): | |
return lambda rec_func: zero_val | |
def Succ(nat): | |
return lambda zero_val: lambda rec_func: rec_func(nat) | |
def add(a): | |
return (lambda b: |
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
using System; | |
using System.Threading; | |
// S is the type stored for successful computations, E for errors | |
public struct Result<S, E> | |
{ | |
private bool isSuccessful; | |
private S successValue; | |
private E errorValue; |
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
from timeit import timeit | |
a = list(range(6)) | |
num = 1_000_000 | |
print("toons's: ", timeit(""" | |
i = iter(islice(iter(a), 0, len(a), 2)) | |
j = iter(islice(iter(a), 1, len(a), 2)) | |
try: |
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
-- save as HaskellCheatsheet.hs | |
module HaskellCheatsheet where | |
-- On Windows, I sometimes have to remove the module line above | |
-- in order to get GHC to compile the file as an executable instead | |
-- of a library. | |
-- Single line comment | |
{- |
NewerOlder