/* * Verrückte Turing-Maschinen — A turing complete game * Copyright (C) 2016 Christian Fraß * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ module lib_brauch { /** * @author kcf */ export type typ_brauch = {[domäne : string] : typ_signatur}; /** * @author kcf */ export function erstellen ( ) : typ_brauch { return {}; } /** * @author kcf */ export function umsetzen ( brauch : typ_brauch, domaene : string, implementierung : typ_signatur ) : void { if (domaene in brauch) { let meldung : string = ("Domäne '" + domaene + "' bereits vorhanden"); throw (new Error(meldung)); } else { brauch[domaene] = implementierung; } } /** * @author kcf */ export function anwenden ( brauch : typ_brauch, domaene : string ) : typ_signatur { if (! (domaene in brauch)) { let meldung : string = ("keine Implementierung für Domäne '" + domaene + "' vorhanden"); throw (new Error(meldung)); } else { return brauch[domaene]; } } }