L-system basics

productions = {"a""abc", "b"->"ac", "c ... ;"b"} ; g[x_] := StringReplace[x, productions] NestList[g, "a", 5]//TableForm

a
abc
abcacb
abcacbabcbac
abcacbabcbacabcacbacabcb
abcacbabcbacabcacbacabcbabcacbabcbacabcbabcacbac

Square (ordinary repetition)

    A square is a non-empty string (word) of the form  uu.

Abelian Square (permutation repetition)

s[x_String] := Apply[Plus, Characters[x]] ; 

    A string  uv,  
    where  
u  and  v  are non-empty strings,
    is an abelian square if  s[
u] = s[v].

    Example:   uv   =   abacdbadac

s["abacd"] s["badac"]

2 a + b + c + d

2 a + b + c + d


Created by Mathematica  (February 18, 2004)