Skip to content

Commit

Permalink
Deploying to gh-pages from @ 4efe0eb 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowMitia committed Aug 23, 2023
1 parent ac0c737 commit 1322ff6
Show file tree
Hide file tree
Showing 57 changed files with 115 additions and 115 deletions.
2 changes: 1 addition & 1 deletion contents/IFS/IFS.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/approximate_counting/approximate_counting.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contents/barnsley/barnsley.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/barnsley/code/coconut/barnsley.coco
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ data Point(x=0, y=0):
return Point(x, y)


def chaos_game(initial_location is Point, hutchinson_op, probabilities):
def chaos_game(Point(initial_location), hutchinson_op, probabilities):
point = initial_location
while True:
yield (point := choices(hutchinson_op, probabilities) @ point)
Expand Down
2 changes: 1 addition & 1 deletion contents/bitlogic/bitlogic.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/box_muller/box_muller.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/box_muller/box_muller_rejection.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/code_reviews/code_reviewers.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/computer_graphics/computer_graphics.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/computus/computus.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/convolutions/1d/1d.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/convolutions/2d/2d.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/convolutions/convolutions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/convolutions/multiplication/multiplication.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/cooley_tukey/cooley_tukey.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/cryptography/cryptography.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/data_compression/data_compression.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/data_structures/data_structures.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/decision_problems/decision_problems.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/domain_coloring/domain_coloring.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions contents/euclidean_algorithm/code/coconut/euclidean.coco
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
def euclid_sub(a is int, 0) = a
addpattern def euclid_sub(0, b is int) = b
def euclid_sub(int(a), 0) = a
addpattern def euclid_sub(0, int(b)) = b

addpattern def euclid_sub(a is int, b is int):
addpattern def euclid_sub(int(a), int(b)):
if a < b:
return euclid_sub(a, b - a)
elif b < a:
return euclid_sub(a - b, b)
return a


def euclid_mod(a is int, 0) = a
addpattern def euclid_mod(0, b is int) = b
def euclid_mod(int(a), 0) = a
addpattern def euclid_mod(0, int(b)) = b

addpattern def euclid_mod(a is int, b is int) = euclid_mod(b, a % b)
addpattern def euclid_mod(int(a), int(b)) = euclid_mod(b, a % b)

if __name__ == '__main__':
print('[#]\nModulus-based euclidean algorithm result:')
Expand Down
26 changes: 13 additions & 13 deletions contents/euclidean_algorithm/euclidean_algorithm.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions contents/flood_fill/code/coconut/flood_fill.coco
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ import numpy as np


data Point(x, y):
def __add__(self, other is Point) = Point(self.x + other.x, self.y + other.y)
def __add__(self, Point(other)) = Point(self.x + other.x, self.y + other.y)


# This function is necessary, because negative indices wrap around the
# array in Coconut.
def inbounds(canvas_shape, location is Point) =
def inbounds(canvas_shape, Point(location)) =
min(location) >= 0 and location.x < canvas_shape[0] and location.y < canvas_shape[1]


def find_neighbours(canvas, location is Point, old_value):
def find_neighbours(canvas, Point(location), old_value):
possible_neighbours = ((Point(0, 1), Point(1, 0), Point(0, -1), Point(-1, 0))
|> map$(location.__add__))

yield from possible_neighbours |> filter$(x -> (inbounds(canvas.shape, x)
and canvas[x] == old_value))


def stack_fill(canvas, location is Point, old_value, new_value):
def stack_fill(canvas, Point(location), old_value, new_value):
if new_value == old_value or not inbounds(canvas.shape, location):
return

Expand All @@ -33,7 +33,7 @@ def stack_fill(canvas, location is Point, old_value, new_value):
stack.extend(find_neighbours(canvas, current_location, old_value))


def queue_fill(canvas, location is Point, old_value, new_value):
def queue_fill(canvas, Point(location), old_value, new_value):
if new_value == old_value or not inbounds(canvas.shape, location):
return

Expand All @@ -49,7 +49,7 @@ def queue_fill(canvas, location is Point, old_value, new_value):
queue.append(neighbour)


def recursive_fill(canvas, location is Point, old_value, new_value):
def recursive_fill(canvas, Point(location), old_value, new_value):
if new_value == old_value or not inbounds(canvas.shape, location):
return

Expand Down
22 changes: 11 additions & 11 deletions contents/flood_fill/flood_fill.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/gaussian_elimination/gaussian_elimination.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/gift_wrapping/gift_wrapping.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/graham_scan/graham_scan.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/how_to_contribute/how_to_contribute.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions contents/huffman_encoding/code/coconut/huffman.coco
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ from bisect import bisect
class Tree

data Empty() from Tree
data Leaf(char, n is int) from Tree:
data Leaf(char, int(n)) from Tree:
def __str__(self):
return f'Leaf({self.char}, {self.n})'

__repr__ = __str__

data Node(left is Tree, right is Tree) from Tree:
data Node(Tree(left), Tree(right)) from Tree:
def __str__(self):
return f'Node({str(self.left)}, {str(self.right)})'
__repr__ = __str__
Expand Down Expand Up @@ -52,7 +52,7 @@ def build_huffman_tree(message):

def build_codebook(Empty(), code='') = []
addpattern def build_codebook(Leaf(char, n), code='') = [(char, code)]
addpattern def build_codebook(Node(left, right), code='') =
addpattern def build_codebook(Node(left, right), code='') =
build_codebook(left, code+'0') + build_codebook(right, code+'1')

def huffman_encode(codebook, message):
Expand Down
8 changes: 4 additions & 4 deletions contents/huffman_encoding/huffman_encoding.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/introduction/introduction.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/jarvis_march/code/coconut/jarvis_march.coco
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ data point(x=0, y=0):
return f'({self.x}, {self.y})'

# Is the turn counter-clockwise?
def counter_clockwise(p1 is point, p2 is point, p3 is point) =
def counter_clockwise(point(p1), point(p2), point(p3)) =
(p3.y - p1.y) * (p2.x - p1.x) >= (p2.y - p1.y) * (p3.x - p1.x)


Expand Down
4 changes: 2 additions & 2 deletions contents/jarvis_march/jarvis_march.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/matrix_methods/matrix_methods.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/metropolis/metropolis.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import random
data point(x, y):
def __abs__(self) = (self.x, self.y) |> map$(pow$(?, 2)) |> sum |> math.sqrt

def in_circle(p is point, radius = 1):
def in_circle(point(p), radius = 1):
"""Return True if the point is in the circle and False otherwise."""
return abs(p) < radius

Expand Down
6 changes: 3 additions & 3 deletions contents/monte_carlo_integration/monte_carlo_integration.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/notation/notation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/physics_solvers/physics_solvers.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/plotting/plotting.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/probability_distributions/distributions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/quantum_information/quantum_information.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/quantum_systems/quantum_systems.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/split-operator_method/split-operator_method.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/stacks_and_queues/stacks_and_queues.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/thomas_algorithm/thomas_algorithm.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions contents/tree_traversal/code/coconut/tree_traversal.coco
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ def dfs_recursive_postorder(Node(value, children)):

def dfs_recursive_inorder_btree(Node(value, children)):
"""A depth first search approach for printing all values in a binary tree."""
case len(children):
match 2:
match len(children):
case 2:
dfs_recursive_inorder_btree(children[0])
print(value, end=' ')
dfs_recursive_inorder_btree(children[1])
match 1:
case 1:
dfs_recursive_inorder_btree(children[0])
print(value, end=' ')
match 0:
case 0:
print(value, end=' ')
else:
print('Invalid binary tree')

def dfs_stack(node is Node):
def dfs_stack(Node(node)):
"""A depth first approach for printing out all values in a tree using a stack."""
stack = [node]
while stack:
Expand All @@ -38,7 +38,7 @@ def dfs_stack(node is Node):
for child in current_node.children:
stack.append(child)

def bfs_queue(node is Node):
def bfs_queue(Node(node)):
"""A breadth first search approach for printing out all values in a tree."""
queue = deque([node])
while queue:
Expand Down
26 changes: 13 additions & 13 deletions contents/tree_traversal/tree_traversal.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contents/verlet_integration/verlet_integration.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion search_index.json

Large diffs are not rendered by default.

0 comments on commit 1322ff6

Please sign in to comment.