Skip to content

Instantly share code, notes, and snippets.

View bwbg's full-sized avatar

Spencer.HM bwbg

  • Attendorn, Germany
View GitHub Profile
@bwbg
bwbg / lib.rs
Created April 15, 2021 20:47
A naive approach implementing a tree with associated data
pub mod data {
pub struct Tree<A> {
value: A,
children: Vec<Tree<A>>,
}
impl<A> Tree<A> {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Construction
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- IsomorphieVonBaeumen.hs
-- Eine Haskell-Implementierung der Einsendeaufgabe 01613 4.4
import Data.Maybe (isJust, fromJust)
-- ------------------------------------------------------------------------
-- Die Datenstruktur für den Binärbaum
-- ------------------------------------------------------------------------
data Tree a = Node { value :: a, left :: Tree a, right :: Tree a }
ASCII-Art der Eingabedaten/Baumstruktur
1
/ \
/ \
2 9
/ \
4 5
program Aufgabe(input, output);
type
tRefIndexListe = ^tIndexListe;
tIndexListe = record
index:integer;
wert:String;
next:tRefIndexListe
end;
@bwbg
bwbg / Ausgabe.txt
Last active November 8, 2019 08:33
A := [2,Hund][3,Aal][4,Katze][7,Maus]
x := [3,Tiger]
add(A, x) := [2,Hund][3,Tiger][4,Aal][5,Katze][7,Maus]
program Maximum (input, output);
var
Eingabe : integer;
Zahl : integer;
begin
{ initialization }
Eingabe := 0;
Zahl := 0;
#if !defined(ELEMENT_HPP)
#define ELEMENT_HPP
#include <memory>
#include <iostream>
template<class T>
struct Element
{
using ElementPtr = std::unique_ptr<Element<T>>;
@bwbg
bwbg / game.py
Created January 27, 2015 14:58
A TicTacToe implementation
#!/usr/bin/env python3
# -----------------------------------------------------------------------------
# Copyright (c) 2015, Heiko Möllerke
#
# 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:
@bwbg
bwbg / document.py
Last active August 29, 2015 14:13
Get and put dictionaries (documents) from and to the filesystem.
#!/usr/bin/env python3
# -----------------------------------------------------------------------------
# Copyright (c) 2015, Heiko Möllerke
#
# 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:
@bwbg
bwbg / error.py
Last active August 29, 2015 14:06
A Python-implementation of an error monad.
#!/usr/bin/env python3
# -----------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2014, Heiko Möllerke
#
# 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