I would like to define a piecewise function by providing two lists and using a for loop eg:
xlist = {1, 2, 3, 4}
ylist = {4, 5, 6}
f(x):= { ylist[1] if x in [ xlist[1],xlist[2] ];ylist[2] if x in [ xlist[2],xlist[3] ]; ylist[3] if x in [ xlist[3],xlist[4] ]; 0 otherwise}