Question: Does the foldl not accept a function with more than two arguments?

This question stems from a previous question that has been perfectly resolved by acer and Carl Love, but as Carl Love mentioned the foldl function, today I attempted to experience its functionality (In order to understand the foldl or foldr function). But I encountered a small issue. 

s:="[ (0, 1), (1, 2), (1, 10), (2, 3), (3, 4), (4, 5),
(4, 9), (5, 6), (6, 7), (7, 8),(8, 9), (10, 11), (11, 12),
(11, 16), (12, 13), (13, 14), (14, 15), (15, 16)]";
with(StringTools):
L1:= "()[]": L2:= "{}{}":
X:=foldl(SubstituteAll,s,op([L1[1],L2[1]]),op([L1[2],L2[2]]),op([L1[3],L2[3]]),op([L1[4],L2[4]]));

Error, (in StringTools:-SubstituteAll) expecting 3 arguments, but got 2

I find it strange that foldl doesn't recognize SubstituteAll with three arguments. 

Isn't s and op([L1[i], L2[i]]) providing three arguments? Of course, s is constantly changing.

 

The goal is to replace the above string with:

{ {0, 1}, {1, 2}, {1, 10}, {2, 3}, {3, 4}, {4, 5},

    {4, 9}, {5, 6}, {6, 7}, {7, 8},{8, 9}, {10, 11}, {11, 12},

    {11, 16}, {12, 13}, {13, 14}, {14, 15}, {15, 16}}

 

Please Wait...