# symbolic function assignment yields different results than explicit assignment

I am confused as to why the two functions below yield different results (as vs ss)? One function assigns the Piecewise function directly, while the other reads the same function from a list of lists. Why doesn't the second function repeat?

piecewiseLists =
{
{
Piecewise[{{signal, t < 2700.}, {0., 2700. <= t < 5400.}}]
},
{
Piecewise[{{signal, t < 15000.}, {0., 15000. <= t < 30000.}}]
}
};

signal = 1;
a[t_] := Piecewise[{{signal, t < 2700.}, {0., 2700. <= t < 5400.}}]
as[y_, repeat_] := a[Mod[y, repeat]];
Plot[as[t, 5400.], {t, 0, 36000.}]
s[t_] := piecewiseLists[[1, 1]]
ss[y_, repeat_] := s[Mod[y, repeat]];
Plot[ss[t, 5400.], {t, 0, 36000.}]


After implementing @Pirx's solution, I noticed that symbolic assignment of the piecewise function fails if placed within an actual function. My suspicion is that either there is something strange happening with the independent variable being hidden in the symbolic function. Or there is some other weird Context issues that at this point is beyond my understanding.

piecewiseLists = {{Piecewise[{{signal, t < 2700.}, {0.,
2700. <= t < 5400.}}]}, {Piecewise[{{signal, t < 15000.}, {0.,
15000. <= t < 30000.}}]}};
generatePeriodicity[piecewiseLists_] :=
Module[{s, ss},
s[t_] = piecewiseLists[[1, 1]];
ss[y_, repeat_] := s[Mod[y, repeat]];
Plot[ss[t, 5400.], {t, 0, 36000.}]];
generatePeriodicity[piecewiseLists]


The issue is with the delayed evaluation in the second case. Try this:

signal = 1;
a[t_] := Piecewise[{{signal, t < 2700.}, {0., 2700. <= t < 5400.}}]
as[y_, repeat_] := a[Mod[y, repeat]];
Plot[as[t, 5400.], {t, 0, 36000.}]
piecewiseLists = {{Piecewise[{{signal, t < 2700.},
{0., 2700. <= t < 5400.}}]}, {Piecewise[{{signal, t < 15000.},
{0., 15000. <= t < 30000.}}]}};
s[t_] = piecewiseLists[[1, 1]];
ss[y_, repeat_] := s[Mod[y, repeat]];
Plot[ss[t, 5400.], {t, 0, 36000.}]

• So this solution works fine for a dynamic environment. However it fails when I try to define the solution in a function. Any idea why this is true? See the newest edit to the question. Aug 13, 2016 at 12:11
• After reaching out to wolfram through premiere service, the issue I was having is a bug that is fixed in v.11 Aug 18, 2016 at 0:06