-module(lsys).
-export([beginWith/2,removeBegin/3]).
-include_lib("eunit/include/eunit.hrl").

beginWith([A|As],[B|Bs]) when A == B -> beginWith(As,Bs);
beginWith([A|_],[B|_]) when A /= B -> false;
beginWith(_,[]) -> true;
beginWith([],_) -> false.


beginWith_test() ->
    ?assertEqual(true,beginWith("hello world","hell")),
    ?assertEqual(true,beginWith("hello world","hello")),
    ?assertEqual(false,beginWith("hello world","help")),
    ?assertEqual(true,beginWith("hello world","hello world")),
    ?assertEqual(false,beginWith("hello world","hello world!!!")).

removeBegin([M|Ms],[S|Ss]) ->
    removeBegin(Match,Source,beginWith(Source,Match)).
removeBegin([_|Ms],[_|Ss],true) -> removeBegin(Ms,Ss,true);
removeBegin([],[S|Ss],true)     -> [S|Ss];
removeBegin(_,[S|Ss],false)    -> [S|Ss];
removeBegin([],[],_) -> [].

removeBegin_test() ->
    ?assertEqual(" world",
                 removeBegin("hello","hello world")),
    ?assertEqual("hello world",
                 removeBegin("world","hello world")),
    ?assertEqual("hello world",
                 removeBegin("","hello world")),
    ?assertEqual("",
                 removeBegin("","","")).

replaceBegin([M|Ms],[R|Rs],[S|Ss]) -> a.

lsys([A|As],[{[M|Ms],[R|Rs]}|Rules]) -> a.

lsys_test() ->
    ?assertEqual(true,true),
    ?assertEqual(false,false).
