Skip to content

Updated elgohr/Publish-Docker-Github-Action to a supported version (v5) #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@master
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: algorithm-archivists/aaa-langs
username: ${{ github.actor }}
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ This file lists everyone, who contributed to this repo and wanted to show up her
- Henrik Abel Christensen
- K. Shudipto Amin
- Peanutbutter_Warrior
- Thijs Raymakers
7 changes: 5 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ languages_to_import = {
'coconut': ['coconut'],
'go': ['go'],
'rust': ['rustc', 'cargo'],
'kotlin': ['kotlin'],
}

for language, tools in languages_to_import.items():
Expand All @@ -59,8 +60,9 @@ for language, tools in languages_to_import.items():

Export('env')

env['CFLAGS'] = '-Wall -Wextra -Werror'
env['CXXFLAGS'] = '-std=c++17'
env['CCFLAGS'] = '-Wall -Wextra -Werror -pedantic -Wconversion'
env['CFLAGS'] = '-std=gnu99'
env['CXXFLAGS'] = '-std=c++17 -Wold-style-cast'
env['ASFLAGS'] = '--64'
env['COCONUTFLAGS'] = '--target 3.8'

Expand All @@ -78,6 +80,7 @@ languages = {
'java': 'java',
'javascript': 'js',
'julia': 'jl',
'kotlin': 'kt',
'lolcode': 'lol',
'lua': 'lua',
'php': 'php',
Expand Down
5 changes: 4 additions & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
* [Multiplication as a Convolution](contents/convolutions/multiplication/multiplication.md)
* [Convolutions of Images (2D)](contents/convolutions/2d/2d.md)
* [Convolutional Theorem](contents/convolutions/convolutional_theorem/convolutional_theorem.md)
* [Probability Distributions](contents/probability_distributions/distributions.md)
* [Box Muller Transform](contents/box_muller/box_muller.md)
* [How costly is rejection sampling?](contents/box_muller/box_muller_rejection.md)
* [Probability Distributions](contents/probability_distributions/distributions.md)
* [Tree Traversal](contents/tree_traversal/tree_traversal.md)
* [Euclidean Algorithm](contents/euclidean_algorithm/euclidean_algorithm.md)
* [Monte Carlo](contents/monte_carlo_integration/monte_carlo_integration.md)
Expand All @@ -44,5 +46,6 @@
* [Computer Graphics](contents/computer_graphics/computer_graphics.md)
* [Flood Fill](contents/flood_fill/flood_fill.md)
* [Quantum Information](contents/quantum_information/quantum_information.md)
* [Cryptography](contents/cryptography/cryptography.md)
* [Computus](contents/computus/computus.md)
* [Approximate Counting Algorithm](contents/approximate_counting/approximate_counting.md)
184 changes: 184 additions & 0 deletions builders/kotlin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# MIT License
#
# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

"""SCons.Tool.kotlin
Tool-specific initialization for Kotlin.
"""

import SCons.Action
import SCons.Builder
import SCons.Util


class ToolKotlinWarning(SCons.Warnings.SConsWarning):
pass


class KotlinNotFound(ToolKotlinWarning):
pass


SCons.Warnings.enableWarningClass(ToolKotlinWarning)


def _detect(env):
""" Try to detect the kotlinc binary """
try:
return env["kotlinc"]
except KeyError:
pass

kotlin = env.Detect("kotlinc")
if kotlin:
return kotlin

SCons.Warnings.warn(KotlinNotFound, "Could not find kotlinc executable")


#
# Builders
#
kotlinc_builder = SCons.Builder.Builder(
action=SCons.Action.Action("$KOTLINCCOM", "$KOTLINCCOMSTR"),
suffix="$KOTLINCLASSSUFFIX",
src_suffix="$KOTLINSUFFIX",
single_source=True,
) # file by file

kotlin_jar_builder = SCons.Builder.Builder(
action=SCons.Action.Action("$KOTLINJARCOM", "$KOTLINJARCOMSTR"),
suffix="$KOTLINJARSUFFIX",
src_suffix="$KOTLINSUFFIX",
single_source=True,
) # file by file

kotlin_rtjar_builder = SCons.Builder.Builder(
action=SCons.Action.Action("$KOTLINRTJARCOM", "$KOTLINRTJARCOMSTR"),
suffix="$KOTLINJARSUFFIX",
src_suffix="$KOTLINSUFFIX",
single_source=True,
) # file by file


def Kotlin(env, target, source=None, *args, **kw):
"""
A pseudo-Builder wrapper for the kotlinc executable.
kotlinc [options] file
"""
if not SCons.Util.is_List(target):
target = [target]
if not source:
source = target[:]
if not SCons.Util.is_List(source):
source = [source]

result = []
kotlinc_suffix = env.subst("$KOTLINCLASSSUFFIX")
kotlinc_extension = env.subst("$KOTLINEXTENSION")
for t, s in zip(target, source):
t_ext = t
if not t.endswith(kotlinc_suffix):
if not t.endswith(kotlinc_extension):
t_ext += kotlinc_extension

t_ext += kotlinc_suffix
# Ensure that the case of first letter is upper-case
t_ext = t_ext[:1].upper() + t_ext[1:]
# Call builder
kotlin_class = kotlinc_builder.__call__(env, t_ext, s, **kw)
result.extend(kotlin_class)

return result


def KotlinJar(env, target, source=None, *args, **kw):
"""
A pseudo-Builder wrapper for creating JAR files with the kotlinc executable.
kotlinc [options] file -d target
"""
if not SCons.Util.is_List(target):
target = [target]
if not source:
source = target[:]
if not SCons.Util.is_List(source):
source = [source]

result = []
for t, s in zip(target, source):
# Call builder
kotlin_jar = kotlin_jar_builder.__call__(env, t, s, **kw)
result.extend(kotlin_jar)

return result


def KotlinRuntimeJar(env, target, source=None, *args, **kw):
"""
A pseudo-Builder wrapper for creating standalone JAR files with the kotlinc executable.
kotlinc [options] file -d target -include-runtime
"""
if not SCons.Util.is_List(target):
target = [target]
if not source:
source = target[:]
if not SCons.Util.is_List(source):
source = [source]

result = []
for t, s in zip(target, source):
# Call builder
kotlin_jar = kotlin_rtjar_builder.__call__(env, t, s, **kw)
result.extend(kotlin_jar)

return result


def generate(env):
"""Add Builders and construction variables for kotlinc to an Environment."""

env["KOTLINC"] = _detect(env)

env.SetDefault(
KOTLINC="kotlinc",
KOTLINSUFFIX=".kt",
KOTLINEXTENSION="Kt",
KOTLINCLASSSUFFIX=".class",
KOTLINJARSUFFIX=".jar",
KOTLINCFLAGS=SCons.Util.CLVar(),
KOTLINJARFLAGS=SCons.Util.CLVar(),
KOTLINRTJARFLAGS=SCons.Util.CLVar(["-include-runtime"]),
KOTLINCCOM="$KOTLINC $KOTLINCFLAGS $SOURCE",
KOTLINCCOMSTR="",
KOTLINJARCOM="$KOTLINC $KOTLINJARFLAGS -d $TARGET $SOURCE",
KOTLINJARCOMSTR="",
KOTLINRTJARCOM="$KOTLINC $KOTLINRTJARFLAGS -d $TARGET $SOURCE",
KOTLINRTJARCOMSTR="",
)

env.AddMethod(Kotlin, "Kotlin")
env.AddMethod(KotlinJar, "KotlinJar")
env.AddMethod(KotlinRuntimeJar, "KotlinRuntimeJar")


def exists(env):
return _detect(env)
8 changes: 4 additions & 4 deletions contents/IFS/IFS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ To begin the discussion of Iterated Function Systems (IFSs), we will first discu
<img class="center" src="res/IFS_triangle_1.png" alt="Sierpinsky Triangle Chaos Game" style="width:100%">

This image is clearly a set of triangles embedded in a larger triangle in such a way that it can be continually cut into three identical pieces and still retain its internal structure.
This idea is known as self-similarity {{"self-similar" | cite }}, and it is usually the first aspect of fractals to catch an audience's attention.
In fact, there are plenty of uses of fractals and their mathematical underpinnings, such as estimating the coastline of Britain {{ "mandelbrot1967long" | cite}}, identifying fingerprints {{ "jampour2010new" | cite }}, and image compression {{ "fractal-compression" | cite }}{{ "saupe1994review" | cite }}.
This idea is known as self-similarity {{ "self-similar" | cite }}, and it is usually the first aspect of fractals to catch an audience's attention.
In fact, there are plenty of uses of fractals and their mathematical underpinnings, such as estimating the coastline of Britain {{ "mandelbrot1967long" | cite }}, identifying fingerprints {{ "jampour2010new" | cite }}, and image compression {{ "fractal-compression" | cite }}{{ "saupe1994review" | cite }}.
In many more rigorous definitions, a fractal can be described as any system that has a non-integer Hausdorff dimension {{ "3b1bfractal" | cite }}{{ "hausdorff" | cite }}{{ "gneiting2012estimators" | cite }}.
Though this is an incredibly interesting concept, the discussion of this chapter will instead focus on methods to generate fractal patterns through iterated function systems.

Expand All @@ -41,7 +41,7 @@ f_3(P) &= \frac{P + C}{2}\\
$$

Each function will read in a particular location in space (here, $$P \in \mathbb{R}^2$$) and output a new location that is the midpoint between the input location and $$A$$, $$B$$, or $$C$$ for $$f_1$$, $$f_2$$, and $$f_3$$ respectively.
The union of all of these functions (the set of all possible functions available for use) is often notated as the _Hutchinson operator_ {{ "hutchinson-operator" | cite }}{{ "hutchinson1981fractals" | cite}}, and for this case it would look like this:
The union of all of these functions (the set of all possible functions available for use) is often notated as the _Hutchinson operator_ {{ "hutchinson-operator" | cite }}{{ "hutchinson1981fractals" | cite }}, and for this case it would look like this:

$$
H(P) = \bigcup_{i=1}^3f_i(P)
Expand Down Expand Up @@ -208,7 +208,7 @@ If you are interested, please let me know and I will be more than willing to add
Here is a video describing iterated function systems:

<div style="text-align:center">
<iframe width="560" height="315" src="https://www.youtube.com/embed/nIIp-vo8rHg"
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/nIIp-vo8rHg"
frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; pic
ture-in-picture" allowfullscreen></iframe>
</div>
Expand Down
6 changes: 3 additions & 3 deletions contents/IFS/code/c/IFS.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ void chaos_game(struct point *in, size_t in_n, struct point *out,
}

int main() {
const int point_count = 10000;
const size_t point_count = 10000;

struct point shape_points [3] = {{0.0,0.0}, {0.5,sqrt(0.75)}, {1.0,0.0}};
struct point out_points[point_count];

srand(time(NULL));
srand((unsigned int)time(NULL));

chaos_game(shape_points, 3, out_points, point_count);

FILE *fp = fopen("sierpinksi.dat", "w+");

for (int i = 0; i < point_count; ++i) {
for (size_t i = 0; i < point_count; ++i) {
fprintf(fp, "%f\t%f\n", out_points[i].x, out_points[i].y);
}

Expand Down
2 changes: 1 addition & 1 deletion contents/affine_transformations/affine_transformations.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ I think that is a nice note to end on: affine transformations are linear transfo
Here is a video describing affine transformations:

<div style="text-align:center">
<iframe width="560" height="315" src="https://www.youtube.com/embed/E3Phj6J287o" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/E3Phj6J287o" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>

<script>
Expand Down
2 changes: 1 addition & 1 deletion contents/approximate_counting/approximate_counting.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ This was probably more useful in 1978 than it is now, but it's still nice to kee
Here is a video describing the Approximate Counting Algorithm:

<div style="text-align:center">
<iframe width="560" height="315" src="https://www.youtube.com/embed/c4RJhPsc14s"
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/c4RJhPsc14s"
frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; pic
ture-in-picture" allowfullscreen></iframe>
</div>
Expand Down
9 changes: 5 additions & 4 deletions contents/approximate_counting/code/c/approximate_counting.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ double increment(double v, double a)
// It returns n(v, a), the approximate count
double approximate_count(size_t n_items, double a)
{
int v = 0;
double v = 0;
for (size_t i = 0; i < n_items; ++i) {
v = increment(v, a);
}
Expand All @@ -61,9 +61,10 @@ void test_approximation_count(size_t n_trials, size_t n_items, double a,
for (size_t i = 0; i < n_trials; ++i) {
sum += approximate_count(n_items, a);
}
double avg = sum / n_trials;
double avg = sum / (double)n_trials;

if (fabs((avg - n_items) / n_items) < threshold){
double items = (double)n_items;
if (fabs((avg - items) / items) < threshold){
printf("passed\n");
}
else{
Expand All @@ -73,7 +74,7 @@ void test_approximation_count(size_t n_trials, size_t n_items, double a,

int main()
{
srand(time(NULL));
srand((unsigned int)time(NULL));

printf("[#]\nCounting Tests, 100 trials\n");
printf("[#]\ntesting 1,000, a = 30, 10%% error\n");
Expand Down
2 changes: 1 addition & 1 deletion contents/barnsley/barnsley.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ We'll definitely come back to this soon, I just wanted to briefly mention it now
Here is a video describing the Barnsley fern:

<div style="text-align:center">
<iframe width="560" height="315" src="https://www.youtube.com/embed/xoXe0AljUMA"
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/xoXe0AljUMA"
frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; pic
ture-in-picture" allowfullscreen></iframe>
</div>
Expand Down
2 changes: 1 addition & 1 deletion contents/bitlogic/bitlogic.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ That's about it for bitlogic. I realize it was a bit long, but this is absolutel
Here is a video describing the contents of this chapter:

<div style="text-align:center">
<iframe width="560" height="315" src="https://www.youtube.com/embed/zMuEk44Ufkw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/zMuEk44Ufkw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>

<script>
Expand Down
Loading