Q:

Synthetically organizing several statements connected by "or"

I want to make a plot where I show several pulses at different times. 
I have the list l with the time of each pulse, for example
l=[1.,2.,24.]

and I have the duration d of the pulse, for example d=0.2. 
I can do the plot in the following way: 
import numpy as np
import matplotlib.pyplot as plt
t=np.linspace(0.,30,1000)
l=[1.,2.,24.]
d=0.2 
def pulse(t):
    if t<l[0]:
        L = 0.
    elif l[0]<=t<l[0]+d or l[1]<=t<l[1]+d or l[2]<=t<l[2]+d:
        L = 1
    else:
        L=0.
    return L

plt.figure(1)
P=map(pulse,t)    
plt.plot(t,P)
plt.show()

Of course, if len(l) becomes very large I cannot use this procedure, that is, I cannot write by hand a very long chain of or. How can I write the algorithm in a more synthetic way?

A:

You can test several different conditions by using a for loop. For example:
def pulse(t):
    L = 0
    for i in range(len(l)):
        if l[i] <= t < l[i] + d:
            L += 1
    return L

