diff --git a/index.html b/index.html index 7ae2716..da5108f 100644 --- a/index.html +++ b/index.html @@ -58,7 +58,7 @@ }); }); }); -

c++misc
bubble-sort.cppmath.cppmultithreading.cppnamespace.cppsignals.cppsmart-pointers.cppvectors.cpp

c++algos
binary-search.cppfind-adjacent.cppfor-each.cpp

pythonmisc
alu-in-python.pybubble-sort.pycombinations-with-replacement.pycomposing-functions.pyenumerate.pyerlang-b-formula.pyforeign-function-library.pyfunction-wrappers.pyfunctools-cache.pyglide-typing-problem.pylinked-list-using-recordclass.pynumpy-operators.pypandas-operators.pypartial-functions.pyregular-expression.pysobel-filter-using-opencl.py

pythonci
genetic-algorithm-optimization.pyparticle-swarm-optimisation.py

pythonml
backpropagation.pyconvolutional-neural-network.pydelta-learning-algorithm.pygradient-descent-algorithm.pyk-nearest-neighbors-classifier.pylinear-threshold-unit.pynumpy-linear-relu.pywidrow-hoff-learning-algorithm.py

pythoneuler
#1-multiples-of-3-and-5.py#2-even-fibonacci-numbers.py#3-largest-prime-factor.py#4-largest-palindrome-product.py#5-smallest-multiple.py#6-sum-square-difference.py#7-10001st-prime.py#8-largest-product-in-a-series.py#9-special-pythagorean-triplet.py#10-summation-of-primes.py#11-largest-product-in-grid.py#12-highly-divisible-triangular-number.py#13-large-sum.py#14-longest-collatz-sequence.py#15-lattice-paths.py#16-power-digit-sum.py#17-number-letter-counts.py

pythoncompilers
ast-constant-folding.pyast-to-tac-to-llvm.pydsl-in-python.pyfor-loop-implementation.pyloop-tiling-optimization.pyopencl-in-python.pyoperator-fusion-on-parse-tree.pyparallelization-optimization.pyshunting-yard-algorithm.pytokenizer-using-generator-in-python.pyvectorization-optimization.py

assemblyx86
hello-x86.asm

verilogmisc
intro.v

veriloggates
and16.vand.vdmux4way.vdmux8way.vdmux.vmux4way16.vmux8way16.vmux16.vmux.vnand.vnot16.vnot.vor8way.vor16.vor.vxor.v

cmisc
header-files.clinked-list.cmacros.cmemory.cpointers.cvalist.c

c++miscalgos^

misc^

bubble-sort.cppmath.cppmultithreading.cppnamespace.cppsignals.cppsmart-pointers.cppvectors.cpp

bubble-sort.cpp

#include <iostream>
+    

c++misc
bubble-sort.cppmath.cppmultithreading.cppnamespace.cppsignals.cppsmart-pointers.cppvectors.cpp

c++algos
binary-search.cppfind-adjacent.cppfor-each.cpp

pythonmisc
alu-in-python.pybubble-sort.pycombinations-with-replacement.pycomposing-functions.pyenumerate.pyerlang-b-formula.pyforeign-function-library.pyfunction-wrappers.pyfunctools-cache.pyglide-typing-problem.pylinked-list-using-recordclass.pynumpy-operators.pypandas-operators.pypartial-functions.pyregular-expression.pysobel-filter-using-opencl.py

pythonci
genetic-algorithm-optimization.pyparticle-swarm-optimisation.py

pythonml
backpropagation.pyconvolutional-neural-network.pydelta-learning-algorithm.pygradient-descent-algorithm.pyk-nearest-neighbors-classifier.pylinear-threshold-unit.pynumpy-linear-relu.pywidrow-hoff-learning-algorithm.py

pythoneuler
#1-multiples-of-3-and-5.py#2-even-fibonacci-numbers.py#3-largest-prime-factor.py#4-largest-palindrome-product.py#5-smallest-multiple.py#6-sum-square-difference.py#7-10001st-prime.py#8-largest-product-in-a-series.py#9-special-pythagorean-triplet.py#10-summation-of-primes.py#11-largest-product-in-grid.py#12-highly-divisible-triangular-number.py#13-large-sum.py#14-longest-collatz-sequence.py#15-lattice-paths.py#16-power-digit-sum.py#17-number-letter-counts.py

pythoncompilers
ast-constant-folding.pyast-to-tac-to-llvm.pydsl-in-python.pyfor-loop-implementation.pyloop-tiling-optimization.pyopencl-in-python.pyoperator-fusion-on-parse-tree.pyparallelization-optimization.pyshunting-yard-algorithm.pytokenizer-using-generator-in-python.pyvectorization-optimization.py

assemblyx86
hello-x86.asm

verilogmisc
intro.v

veriloggates
and16.vand.vdmux4way.vdmux8way.vdmux.vmux4way16.vmux8way16.vmux16.vmux.vnand.vnot16.vnot.vor8way.vor16.vor.vxor.v

cmisc
header-files.clinked-list.cmacros.cmemory.cpointers.cvalist.c

c++miscalgos^

misc^

bubble-sort.cppmath.cppmultithreading.cppnamespace.cppsignals.cppsmart-pointers.cppvectors.cpp

[bubble-sort.cpp]

#include <iostream>
 #include <vector>
 
 constexpr void print_elements_in_vector(std::vector<int> numbers) {
@@ -87,7 +87,7 @@
     print_elements_in_vector(numbers); // 10 14 27 33 35
 }
 
-

math.cpp

#include <iostream>
+

[math.cpp]

#include <iostream>
 #include <cmath>
 
 int main() {
@@ -152,7 +152,7 @@
     std::cout << fma(42.5, 10, 200) << std::endl; // 625
 }
 
-

multithreading.cpp

#include <iostream>
+

[multithreading.cpp]

#include <iostream>
 #include <pthread.h>
 
 constexpr int max_threads = 5;
@@ -192,7 +192,7 @@
     // thread_id: 140701949382800
 }
 
-

namespace.cpp

#include <iostream>
+

[namespace.cpp]

#include <iostream>
 
 // define namespace
 namespace my_functions {
@@ -205,7 +205,7 @@
     my_functions::function(); // called: my_functions::function
 }
 
-

signals.cpp

#include <iostream>
+

[signals.cpp]

#include <iostream>
 #include <csignal>
 #include <unistd.h>
 
@@ -229,7 +229,7 @@
    // signal: 2
 }
 
-

smart-pointers.cpp

// smart pointers handle allocation and deletion of memory
+

[smart-pointers.cpp]

// smart pointers handle allocation and deletion of memory
 
 #include <memory>
 #include <iostream>
@@ -253,7 +253,7 @@
     function_using_data(); // 0 0 0 0 0
 }
 
-

vectors.cpp

#include <iostream>
+

[vectors.cpp]

#include <iostream>
 #include <vector>
 #include <string>
 #include <format>
@@ -275,7 +275,7 @@
     std::cout << strings[0] << " " << strings[1] << std::endl; // hello c++
 }
 
-

algos^

binary-search.cppfind-adjacent.cppfor-each.cpp

binary-search.cpp

#include <algorithm>
+

algos^

binary-search.cppfind-adjacent.cppfor-each.cpp

[binary-search.cpp]

#include <algorithm>
 #include <vector>
 #include <iostream>
 
@@ -291,7 +291,7 @@
     // found value
 }
 
-

find-adjacent.cpp

#include <algorithm>
+

[find-adjacent.cpp]

#include <algorithm>
 #include <vector>
 #include <iostream>
 
@@ -309,7 +309,7 @@
     // 10, 20
 }
 
-

for-each.cpp

#include <algorithm>
+

[for-each.cpp]

#include <algorithm>
 #include <vector>
 #include <iostream>
 
@@ -326,7 +326,7 @@
     // 2 4 6 8 10
 }
 
-


pythonmisccimleulercompilers^

misc^

alu-in-python.pybubble-sort.pycombinations-with-replacement.pycomposing-functions.pyenumerate.pyerlang-b-formula.pyforeign-function-library.pyfunction-wrappers.pyfunctools-cache.pyglide-typing-problem.pylinked-list-using-recordclass.pynumpy-operators.pypandas-operators.pypartial-functions.pyregular-expression.pysobel-filter-using-opencl.py

[alu-in-python.py]

"""
 An ALU is a combinational logic circuit that performs
 arithmetic and bitwise operations on input bits. This
 is a 16-bit implementation.
@@ -495,7 +495,7 @@
         assert zr == int(values[9])
         assert ng == int(values[10])
 
-

bubble-sort.py

# https://en.wikipedia.org/wiki/Bubble_sort
+

[bubble-sort.py]

# https://en.wikipedia.org/wiki/Bubble_sort
 
 unsorted_list = [14, 33, 27, 35, 10]
 for i in range(len(unsorted_list)):
@@ -508,7 +508,7 @@
 
 print(unsorted_list) # [10, 14, 27, 33, 35]
 
-

combinations-with-replacement.py

from itertools import combinations_with_replacement
+

[combinations-with-replacement.py]

from itertools import combinations_with_replacement
 
 my_list = ['A', 'B']
 combinations = []
@@ -524,7 +524,7 @@
 print(combinations)
 # [('A',), ('B',), ('A', 'A'), ('A', 'B'), ('B', 'B')]
 
-

composing-functions.py

import functools
+

[composing-functions.py]

import functools
 import operator
 
 def compose(a, b): return lambda x: a(b(x))
@@ -541,7 +541,7 @@
 numbers = [1, 2, 3, 4, 5]
 print(functools.reduce(operator.add, numbers)) # 15
 
-

enumerate.py

my_list = ["Zero", "One", "Two", "Three", "Four", "Five"]
+

[enumerate.py]

my_list = ["Zero", "One", "Two", "Three", "Four", "Five"]
 
 for item in enumerate(my_list): print(item)
 # (0, 'First')
@@ -550,7 +550,7 @@
 # (3, 'Fourth')
 # (4, 'Fifth')
 
-

erlang-b-formula.py

# https://en.wikipedia.org/wiki/Erlang_(unit)#Erlang_B_formula
+

[erlang-b-formula.py]

# https://en.wikipedia.org/wiki/Erlang_(unit)#Erlang_B_formula
 
 from math import factorial
 
@@ -562,7 +562,7 @@
 
 print(erlang(90, 107)) # 0.008799105244742682
 
-

foreign-function-library.py

"""
+

[foreign-function-library.py]

"""
 A foreign function library is a library written in
 languages other than the language it is being called
 from. E.g., a Python program calling function from C
@@ -602,7 +602,7 @@
 libc = ctypes.CDLL('libc.dylib')
 libc.printf(b"hello world\n") # hello world
 
-

function-wrappers.py

"""
+

[function-wrappers.py]

"""
 Function wrappers can be used to modify behavior of function
 or method. The wraps decorator copies over the function name,
 docstring, and arguments list to the wrapper function. This
@@ -623,7 +623,7 @@
 
 power(2, 3) # call to power, args: (2, 3), kwargs: {}
 
-

functools-cache.py

"""
+

[functools-cache.py]

"""
 The lru_cache decorator caches the results of a function
 call with a given set of arguments. This is useful for
 functions that are computationally expensive and have a
@@ -647,7 +647,7 @@
 print(fib_cache.cache_info())
 # CacheInfo(hits=28, misses=31, maxsize=128, currsize=31)
 
-

glide-typing-problem.py

"""
+

[glide-typing-problem.py]

"""
 Glide typing is the feature on mobile devices that allows
 users to type by swiping across the keyboard. The keyboard
 will predict the word based on the path of the swipe.
@@ -676,7 +676,7 @@
 # first match
 print(matches[0][0]) # hello
 
-

linked-list-using-recordclass.py

"""
+

[linked-list-using-recordclass.py]

"""
 A linked list is a linear data structure where each element
 is the data and reference to next element. The last element
 reference to None and an empty linked list has a None head.
@@ -739,7 +739,7 @@
 
 print(ll) # [5, 10, 20, 25]
 
-

numpy-operators.py

import numpy as np
+

[numpy-operators.py]

import numpy as np
 
 # numpy array basics
 
@@ -926,7 +926,7 @@
 #  [22 24 26]
 #  [25 27 29]]
 
-

pandas-operators.py

import pandas as pd
+

[pandas-operators.py]

import pandas as pd
 
 # creating series (one-dimensional array)
 simple_series = pd.Series([42, 55, 73], dtype='f8')
@@ -1038,7 +1038,7 @@
 # neutron       73.0    28
 # proton        55.0    496
 
-

partial-functions.py

"""
+

[partial-functions.py]

"""
 A partial function is a function with some arguments already
 filled in. This is useful for creating new functions from
 existing functions.
@@ -1063,7 +1063,7 @@
 print(list(map(cube, numbers)))
 # [1, 8, 27, 64, 125]
 
-

regular-expression.py

import re
+

[regular-expression.py]

import re
 
 text = "some random text to test regular expressions"
 date = "2017-07-16"
@@ -1088,7 +1088,7 @@
 print(re.match("20[01][0-9].*[0-9][0-9].*[0-9][0-9]", date) != None)
 # True
 
-

sobel-filter-using-opencl.py

"""
+

[sobel-filter-using-opencl.py]

"""
 A Sobel filter is an edge detection filter. It's a 3x3
 convolution commonly used in image processing.
 """
@@ -1160,7 +1160,7 @@
 # show image
 # output_image.show()
 
-

ci^

genetic-algorithm-optimization.pyparticle-swarm-optimisation.py

genetic-algorithm-optimization.py

# https://en.wikipedia.org/wiki/Genetic_algorithm
+

ci^

genetic-algorithm-optimization.pyparticle-swarm-optimisation.py

[genetic-algorithm-optimization.py]

# https://en.wikipedia.org/wiki/Genetic_algorithm
 import random
 import math
 # https://pypi.org/project/tabulate/
@@ -1388,7 +1388,7 @@
 #   2  [0, 0, 0, 0, 1, 1, 1, 1]  [10.0, 7.0]     65.000
 #   3  [0, 0, 0, 0, 1, 1, 1, 1]  [10.0, 7.0]     65.000
 
-

particle-swarm-optimisation.py

# https://en.wikipedia.org/wiki/Particle_swarm_optimization
+

[particle-swarm-optimisation.py]

# https://en.wikipedia.org/wiki/Particle_swarm_optimization
 import random
 
 random.seed(42)
@@ -1548,7 +1548,7 @@
     )
 assert (global_best, global_pos) == (-9.33, [0.67, -1.67])
 
-

ml^

backpropagation.pyconvolutional-neural-network.pydelta-learning-algorithm.pygradient-descent-algorithm.pyk-nearest-neighbors-classifier.pylinear-threshold-unit.pynumpy-linear-relu.pywidrow-hoff-learning-algorithm.py

backpropagation.py

# https://en.wikipedia.org/wiki/Backpropagation
+

ml^

backpropagation.pyconvolutional-neural-network.pydelta-learning-algorithm.pygradient-descent-algorithm.pyk-nearest-neighbors-classifier.pylinear-threshold-unit.pynumpy-linear-relu.pywidrow-hoff-learning-algorithm.py

[backpropagation.py]

# https://en.wikipedia.org/wiki/Backpropagation
 import numpy as np
 
 np.random.seed(42)
@@ -1600,7 +1600,7 @@
 #  [0.97090151]
 #  [0.03501066]]
 
-

convolutional-neural-network.py

# https://en.wikipedia.org/wiki/Convolutional_neural_network
+

[convolutional-neural-network.py]

# https://en.wikipedia.org/wiki/Convolutional_neural_network
 import os
 import numpy as np
 import matplotlib.pyplot as plt
@@ -1673,7 +1673,7 @@
 print(loss) # 0.029002553918152263
 print(accuracy) # 0.9906
 
-

delta-learning-algorithm.py

# https://en.wikipedia.org/wiki/Delta_rule
+

[delta-learning-algorithm.py]

# https://en.wikipedia.org/wiki/Delta_rule
 import numpy as np
 from tabulate import tabulate
 
@@ -1753,7 +1753,7 @@
 #  11  [1.0, 3.0, 1.0]   [1, -2, -1]            0    0  [1.0, 3.0, 1.0]
 #  12  [1.0, 3.0, 1.0]   [1, -3, -2]            0    0  [1.0, 3.0, 1.0]
 
-

gradient-descent-algorithm.py

# https://en.wikipedia.org/wiki/Gradient_descent
+

[gradient-descent-algorithm.py]

# https://en.wikipedia.org/wiki/Gradient_descent
 import numpy as np
 import random
 
@@ -1822,7 +1822,7 @@
 # Iteration: 9999, Cost: 430.137723
 # [39.64610036 39.64610036]
 
-

k-nearest-neighbors-classifier.py

# https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm
+

[k-nearest-neighbors-classifier.py]

# https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm
 import numpy as np
 from sklearn import datasets
 from tabulate import tabulate
@@ -1883,7 +1883,7 @@
 # [5.3, 2.5, 1.7, 2.2]        0
 # [4.9, 2.2, 7.0, 0.0]        2
 
-

linear-threshold-unit.py

# https://en.wikipedia.org/wiki/Artificial_neuron
+

[linear-threshold-unit.py]

# https://en.wikipedia.org/wiki/Artificial_neuron
 import numpy as np
 from tabulate import tabulate
 
@@ -1940,7 +1940,7 @@
 # COMBINATION  [1, 0, 0]  [2, -2, 2]          1           1
 # COMBINATION  [0, 1, 0]  [2, -2, 2]          1           0
 
-

numpy-linear-relu.py

"""
+

[numpy-linear-relu.py]

"""
 A simple implementation of linear layer followed by a
 ReLU activation function.
 """
@@ -1975,7 +1975,7 @@
 # check within tolerance
 np.testing.assert_allclose(c_mm_relu, c_np, rtol=1e-5)
 
-

widrow-hoff-learning-algorithm.py

# https://www.cs.princeton.edu/courses/archive/spring13/cos511/scribe_notes/0411.pdf
+

[widrow-hoff-learning-algorithm.py]

# https://www.cs.princeton.edu/courses/archive/spring13/cos511/scribe_notes/0411.pdf
 import numpy as np
 from tabulate import tabulate
 
@@ -2035,7 +2035,7 @@
 #  11  [0.676, 0.484, -0.234]  [-1, 2, 1]    0.059  [0.581, 0.673, -0.14]
 #  12  [0.581, 0.673, -0.14]   [-1, 3, 2]    1.156  [0.597, 0.626, -0.172]
 
-

euler^

#1-multiples-of-3-and-5.py#2-even-fibonacci-numbers.py#3-largest-prime-factor.py#4-largest-palindrome-product.py#5-smallest-multiple.py#6-sum-square-difference.py#7-10001st-prime.py#8-largest-product-in-a-series.py#9-special-pythagorean-triplet.py#10-summation-of-primes.py#11-largest-product-in-grid.py#12-highly-divisible-triangular-number.py#13-large-sum.py#14-longest-collatz-sequence.py#15-lattice-paths.py#16-power-digit-sum.py#17-number-letter-counts.py

euler^

#1-multiples-of-3-and-5.py#2-even-fibonacci-numbers.py#3-largest-prime-factor.py#4-largest-palindrome-product.py#5-smallest-multiple.py#6-sum-square-difference.py#7-10001st-prime.py#8-largest-product-in-a-series.py#9-special-pythagorean-triplet.py#10-summation-of-primes.py#11-largest-product-in-grid.py#12-highly-divisible-triangular-number.py#13-large-sum.py#14-longest-collatz-sequence.py#15-lattice-paths.py#16-power-digit-sum.py#17-number-letter-counts.py

[#1-multiples-of-3-and-5.py]

"""
 Multiples of 3 and 5
 
 If we list all the natural numbers below 10 that are multiples 
@@ -2054,7 +2054,7 @@
 
 print(sum(result)) # 233168
 
-

#2-even-fibonacci-numbers.py

# 2020-10
+

[#2-even-fibonacci-numbers.py]

# 2020-10
 
 """
 Even Fibonacci numbers
@@ -2110,7 +2110,7 @@
 print(sum(result))
 # 4613732
 
-

#3-largest-prime-factor.py

# 2020-10
+

[#3-largest-prime-factor.py]

# 2020-10
 
 """
 Largest prime factor
@@ -2188,7 +2188,7 @@
 print(max(result))
 # 6857
 
-

#4-largest-palindrome-product.py

# 2020-10
+

[#4-largest-palindrome-product.py]

# 2020-10
 
 """
 Largest palindrome product
@@ -2229,7 +2229,7 @@
 print(max(result))
 # 906609
 
-

#5-smallest-multiple.py

# 2020-10
+

[#5-smallest-multiple.py]

# 2020-10
 
 """
 Smallest multiple
@@ -2288,7 +2288,7 @@
 print(result)
 # 232792560
 
-

#6-sum-square-difference.py

# 2020-11
+

[#6-sum-square-difference.py]

# 2020-11
 
 """
 Sum square difference
@@ -2332,7 +2332,7 @@
 print(square_sum - sum_square)
 # 25164150
 
-

#7-10001st-prime.py

# 2020-10
+

[#7-10001st-prime.py]

# 2020-10
 
 """
 10001st prime
@@ -2408,7 +2408,7 @@
 print(result[n - 1])
 # 104743
 
-

#8-largest-product-in-a-series.py

# 2020-11
+

[#8-largest-product-in-a-series.py]

# 2020-11
 
 """
 Largest product in a series
@@ -2497,7 +2497,7 @@
 print(max_product)
 # 23514624000
 
-

#9-special-pythagorean-triplet.py

# 2020-11
+

[#9-special-pythagorean-triplet.py]

# 2020-11
 
 """
 Special Pythagorean triplet
@@ -2535,7 +2535,7 @@
 print(result)
 # 31875000
 
-

#10-summation-of-primes.py

"""
+

[#10-summation-of-primes.py]

"""
 Summation of primes
 
 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
@@ -2572,7 +2572,7 @@
 result = SOE([], 2000000)
 print(sum(result)) # 142913828922
 
-

#11-largest-product-in-grid.py

"""
+

[#11-largest-product-in-grid.py]

"""
 Largest product in grid
 
 In the 20x20 grid below, four numbers along a diagonal line
@@ -2657,7 +2657,7 @@
 result = largest_product(GRID)
 print(result) # 70600674
 
-

#12-highly-divisible-triangular-number.py

"""
+

[#12-highly-divisible-triangular-number.py]

"""
 Highly divisible triangular number
 
 The sequence of triangle numbers is generated by adding the natural numbers. So the 
@@ -2732,7 +2732,7 @@
 print(result[0])
 # 76576500
 
-

#13-large-sum.py

# 2022-07
+

[#13-large-sum.py]

# 2022-07
 
 """
 Large sum
@@ -2851,7 +2851,7 @@
 print(str(result)[0:10])
 # 5537376230
 
-

#14-longest-collatz-sequence.py

# 2022-07
+

[#14-longest-collatz-sequence.py]

# 2022-07
 
 """
 Longest Collatz sequence
@@ -2905,7 +2905,7 @@
 print(longest[0])
 # 837799
 
-

#15-lattice-paths.py

# 2022-07
+

[#15-lattice-paths.py]

# 2022-07
 
 """
 Lattice paths
@@ -2950,7 +2950,7 @@
 print(int(pascal_triangle(21)[20][20]))
 # 137846528820
 
-

#16-power-digit-sum.py

# 2022-07
+

[#16-power-digit-sum.py]

# 2022-07
 
 """
 Power digit sum
@@ -2970,7 +2970,7 @@
 print(pow_sum(2, 1000))
 # 1366
 
-

#17-number-letter-counts.py

# 2022-07
+

[#17-number-letter-counts.py]

# 2022-07
 
 """
 Number letter counts
@@ -3062,7 +3062,7 @@
 print(letters)
 # 21124
 
-

compilers^

ast-constant-folding.pyast-to-tac-to-llvm.pydsl-in-python.pyfor-loop-implementation.pyloop-tiling-optimization.pyopencl-in-python.pyoperator-fusion-on-parse-tree.pyparallelization-optimization.pyshunting-yard-algorithm.pytokenizer-using-generator-in-python.pyvectorization-optimization.py

compilers^

ast-constant-folding.pyast-to-tac-to-llvm.pydsl-in-python.pyfor-loop-implementation.pyloop-tiling-optimization.pyopencl-in-python.pyoperator-fusion-on-parse-tree.pyparallelization-optimization.pyshunting-yard-algorithm.pytokenizer-using-generator-in-python.pyvectorization-optimization.py

[ast-constant-folding.py]

"""
 Constant folding is a form of partial evaluation
 that can be applied to constant expressions to
 reduce the number of instructions in generated
@@ -3116,7 +3116,7 @@
 exec(compile(folded_tree, filename="<ast>", mode="exec"))
 # 25
 
-

ast-to-tac-to-llvm.py

"""
+

[ast-to-tac-to-llvm.py]

"""
 AST is tree representation of source code
 TAC is linear representation of ASTs
 LLVM IR is linear representation of the TAC
@@ -3203,7 +3203,7 @@
 #     ret i32 %t5
 # }
 
-

dsl-in-python.py

"""
+

[dsl-in-python.py]

"""
 This is how to design and use embedded
 domain-specific languages in Python.
 """
@@ -3284,7 +3284,7 @@
 
 interpret(program) # 3
 
-

for-loop-implementation.py

import timeit
+

[for-loop-implementation.py]

import timeit
 
 def not_for_loop(index = 0, elements = [], operation = None):
     if index < len(elements):
@@ -3325,7 +3325,7 @@
 print(timeit.timeit('for_loop([1, 2, 3, 4, 5], lambda x: x.__add__(1))', setup = 'from __main__ import for_loop', number = 100000))
 # 0.08654258819296956
 
-

loop-tiling-optimization.py

"""
+

[loop-tiling-optimization.py]

"""
 Loop tiling optimization is a technique used
 to improve cache efficiency in nested loops.
 """
@@ -3387,7 +3387,7 @@
 print(timeit.timeit(lambda: matmul_tiled(A, B), number=10)) # CPU
 # 6.588905839016661
 
-

opencl-in-python.py

"""
+

[opencl-in-python.py]

"""
 OpenCL can be used to run code on GPUs and other
 accelerators. It's a C API (kernel code looks like 
 C code) and pyopencl is a Python wrapper.
@@ -3462,7 +3462,7 @@
 del queue
 del program
 
-

operator-fusion-on-parse-tree.py

"""
+

[operator-fusion-on-parse-tree.py]

"""
 Operator fusion is a technique to combine or rearrange
 consecutive operations in a parse tree to improve
 efficiency of code execution.
@@ -3491,7 +3491,7 @@
 
 assert simplify_parse_tree(parse_tree) == compiled.co_consts[0]
 
-

parallelization-optimization.py

"""
+

[parallelization-optimization.py]

"""
 Parallelization optimization is a form of optimization
 that aims to improve program performance by parallelizing
 it, i.e. by splitting the program into smaller parts that
@@ -3540,7 +3540,7 @@
     print(f"sum_of_squares_parallel: {timeit.timeit(lambda: sum_of_squares_parallel(n), number=10)}")
     # sum_of_squares_parallel: 6.641842097043991
 
-

shunting-yard-algorithm.py

# https://en.wikipedia.org/wiki/Shunting-yard_algorithm
+

[shunting-yard-algorithm.py]

# https://en.wikipedia.org/wiki/Shunting-yard_algorithm
 PRECEDENCE = { 'func': 3, '^': 2, '/': 1, '*': 1, '+': 0, '-': 0 }
 
 def parse(input_):
@@ -3597,7 +3597,7 @@
 assert parse("3 + 4 * 2 / (1 - 5) ^2 ^3") == "3 4 2 * 1 5 - 2 3 ^ ^ / +"
 assert parse("sin(max(2, 3) / 3 * pi)") == "2 3 max 3 / pi * sin"
 
-

tokenizer-using-generator-in-python.py

import re
+

[tokenizer-using-generator-in-python.py]

import re
 
 token_pattern = r'[a-zA-Z_][a-zA-Z0-9_]*|\d+|<=|>=|==|!=|[<>]=?|=|[+\-*/;(){}]'
 
@@ -3636,7 +3636,7 @@
 # ('OP', '+')
 # ('NUM', '1')
 
-

vectorization-optimization.py

"""
+

[vectorization-optimization.py]

"""
 Vectorization optimization is a technique for optimizing
 programs by transforming sequential operations into
 parallel operations (vector operations).
@@ -3720,7 +3720,7 @@
 #             78 BINARY_OP                0 (+)
 #             82 RETURN_VALUE
 
-

assemblyx86^

x86^

hello-x86.asm

hello-x86.asm

; x86-64 (intel syntax)
+

assemblyx86^

x86^

hello-x86.asm

[hello-x86.asm]

; x86-64 (intel syntax)
     section .text
     global _main
 
@@ -3744,7 +3744,7 @@
 ; $ ./_hello
 ; hello x86
 
-


verilogmiscgates^

misc^

intro.v

[intro.v]

/*
     http://www.techep.csi.cuny.edu/~zhangs/v.html
     iverilog -o intro intro.v; vvp intro
 */
@@ -3759,7 +3759,7 @@
     end
 endmodule
 
-

gates^

and16.vand.vdmux4way.vdmux8way.vdmux.vmux4way16.vmux8way16.vmux16.vmux.vnand.vnot16.vnot.vor8way.vor16.vor.vxor.v

gates^

and16.vand.vdmux4way.vdmux8way.vdmux.vmux4way16.vmux8way16.vmux16.vmux.vnand.vnot16.vnot.vor8way.vor16.vor.vxor.v

[and16.v]

/*
     And16(a, b) : For i = 0..15 out[i] = And(a[i], b[i])
 */
 
@@ -3843,7 +3843,7 @@
     end
 endmodule
 
-

and.v

/*
+

[and.v]

/*
     And(a, b) : If a = b = 1 then out = 1 else out = 0
 */
 
@@ -3882,7 +3882,7 @@
     end
 endmodule
 
-

dmux4way.v

/*
+

[dmux4way.v]

/*
     DMux4way(in, sel) :
         If sel = 00 then { a = in, b = c = d = 0 } else if
            sel = 01 then { b = in, a = c = d = 0 } else if
@@ -3962,7 +3962,7 @@
     end
 endmodule
 
-

dmux8way.v

/*
+

[dmux8way.v]

/*
     DMux8way(in, sel) :
         If sel = 000 then { a = in, b = c = d = e = f = g = h = 0 } else if
            sel = 001 then { b = in, a = c = d = e = f = g = h = 0 } else if
@@ -4076,7 +4076,7 @@
     end
 endmodule
 
-

dmux.v

/*
+

[dmux.v]

/*
     DMux(in, sel) : If sel = 0 then { a = in, b = 0 } else { a = 0, b = in }
 */
 
@@ -4134,7 +4134,7 @@
     end
 endmodule
 
-

mux4way16.v

/*
+

[mux4way16.v]

/*
     Mux4Way16(a, b, c, d, sel) :
         If sel = 00 then out = a else if
            sel = 01 then out = b else if
@@ -4236,7 +4236,7 @@
     end
 endmodule
 
-

mux8way16.v

/*
+

[mux8way16.v]

/*
     Mux8Way16(a, b, c, d, e, f, g, h, sel) :
         If sel = 000 then out = a else if
            sel = 001 then out = b else if
@@ -4372,7 +4372,7 @@
     end
 endmodule
 
-

mux16.v

/*
+

[mux16.v]

/*
     Mux16(a, b, sel) : If sel = 0 then for i = 0..15 out[i] = a[i] else for i = 0..15 out[i] = b[i]
 */
 
@@ -4446,7 +4446,7 @@
     end
 endmodule
 
-

mux.v

/*
+

[mux.v]

/*
     Mux(a, b, sel) : If sel = 0 then out = a else out = b
 */
 
@@ -4511,7 +4511,7 @@
     end
 endmodule
 
-

nand.v

/*
+

[nand.v]

/*
     Nand(a, b) : If a = b = 1 then out = 0 else out = 1
 */
 
@@ -4564,7 +4564,7 @@
     end
 endmodule
 
-

not16.v

/*
+

[not16.v]

/*
     Not16(in) : For i = 0..15 out[i] = Not(in[i])
 */
 
@@ -4648,7 +4648,7 @@
     end
 endmodule
 
-

not.v

/*
+

[not.v]

/*
     Not(in) : If in = 0 then out = 1 else out = 0
 */
 
@@ -4680,7 +4680,7 @@
     end
 endmodule
 
-

or8way.v

/*
+

[or8way.v]

/*
     Or8Way(in) : out = Or(in[0], ..., in[7])
 */
 
@@ -4720,7 +4720,7 @@
     end
 endmodule
 
-

or16.v

/*
+

[or16.v]

/*
     Or16(a, b) : For i = 0..15 out[i] = Or(a[i], b[i])
 */
 
@@ -4804,7 +4804,7 @@
     end
 endmodule
 
-

or.v

/*
+

[or.v]

/*
     Or(a, b) : If a = b = 0 then out = 0 else out = 1
 */
 
@@ -4844,7 +4844,7 @@
     end
 endmodule
 
-

xor.v

/*
+

[xor.v]

/*
     Xor(a, b) : If a<>b then out = 1 else out = 0
 */
 
@@ -4903,7 +4903,7 @@
     end
 endmodule
 
-


cmisc^

misc^

header-files.clinked-list.cmacros.cmemory.cpointers.cvalist.c

[header-files.c]

#include <stdio.h>
 
 // filename.h
 /*
@@ -4921,7 +4921,7 @@
     printf("%d\n", number); // 10
 }
 
-

linked-list.c

// linked list implementation in C
+

[linked-list.c]

// linked list implementation in C
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -5012,7 +5012,7 @@
     print(ll); // 5 10 20 25
 }
 
-

macros.c

#include <stdio.h>
+

[macros.c]

#include <stdio.h>
 #include <stddef.h>
 
 // stringify error messages
@@ -5045,7 +5045,7 @@
    printf("%d\n", max(4,5)); // 5
 }
 
-

memory.c

#include <stdio.h>
+

[memory.c]

#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -5086,7 +5086,7 @@
     free(description);
 }
 
-

pointers.c

#include <stdio.h>
+

[pointers.c]

#include <stdio.h>
 #include <stddef.h>
 
 int main() {
@@ -5105,7 +5105,7 @@
     printf("%d\n", *ip); // 5
 }
 
-

valist.c

#include <stdio.h>
+

[valist.c]

#include <stdio.h>
 #include <stdarg.h>
 
 // declare function (normally in header file)