Skip to content

Instantly share code, notes, and snippets.

View ichistmeinname's full-sized avatar

Sandra Dylus ichistmeinname

View GitHub Profile
######################################################
# Algorithmus aus der Vorlesung
######################################################
#text= "Die Giraffe trinkt Kaffee.";
#sub = "affe";
#i=0;
#while i < text.length && text[i,sub.length] != sub do
# i = i + 1;
#end;
#natRegexp = /(0|[1-9]([0-9])*)/;
# Definition einer FUNKTION(!) für natRegexp
# Matche natRegexp gegen `str` an Position `pos`
def match_0O1Bis90Bis9S(pos,str)
# Es kann folgende Unterscheidung für den nächsten Buchstaben gemacht werden:
# Matche /0/ gegen `str` an Position `pos`
p1 = match_0(pos,str);
# Matche /[1-9][0-9]*/ gegen `str` an Position `pos`
p2 = match_1Bis90Bis9S(pos,str);
# Definition des regulären Ausdrucks
uhrzeitRegexp = /(2[0-3]|[0-1]?[0-9]):[0-5][0-9]/;
# Zeichenkette aus Datei "zeitplan.txt" auslesen
text = IO.read("zeitplan.txt");
# Matche meinen regulären Ausdruck mit `text`,
# gebe alle Vorkommen aus und betrachte Reststring
# für weiteres Matching
#nummern = IO.read("contacts.txt");
class Contact
def initialize(name, phone)
@name = name;
@phone = phone;
end;
# a ist ein eindimensionales array
def removeCell(a,k)
a = a[0,k] + a[k+1,a.size-1];
end;
#p(removeCell([1,2,3,4], 3));
# [1,2,3];
#p("Hallo Welt"[6,4]);
public class SyncPhilosopher implements Runnable {
private Object left;
private Object right;
private int num;
public SyncPhilosopher(int num, Object left, Object right) {
this.left = left;
this.right = right;
@ichistmeinname
ichistmeinname / Counter.java
Last active August 29, 2015 14:01
Third group session for advanced programming.
public class Counter extends Thread {
private String name;
private int count;
private int delay;
public Counter(String name, int delay) {
this.name = name;
this.delay = delay;
this.count = 0;
@ichistmeinname
ichistmeinname / Tree.hs
Created May 21, 2014 13:49
Fifth group session
-- data IntTree = IntLeaf Int
-- | IntBranch IntTree IntTree
-- deriving Show
-- IntLeaf :: Int -> IntTree
-- IntBranch :: IntTree -> IntTree -> IntTree
intTree1 :: IntTree
intTree1 = Branch (Branch (Leaf 21)
(Leaf 5))
(Branch (Leaf 20)
@ichistmeinname
ichistmeinname / Set.hs
Created May 28, 2014 13:38
Sixth group session
module Set where
-- Menge als Funktion?!
type Set a = a -> Bool
-- empty
empty :: Set Int -- Int -> Bool
empty _ = False
-- empty x = const False x
-- empty = const False
@ichistmeinname
ichistmeinname / Automaton.hs
Created June 4, 2014 13:44
Seventh group session
module Automaton where
import Prelude hiding ( repeat )
import Data.List ( find )
data State = State
[(Char, State)] -- transitions
Bool -- final state?
-- prueft, ob ein Automat ein gegebenes Wort akzeptiert