private static Zen <Option <ushort> > IndexOf(Zen <IList <ushort> > s, Zen <IList <ushort> > sub, int current) { return(s.Case( empty: If(sub.IsEmpty(), Some <ushort>((ushort)current), Null <ushort>()), cons: (hd, tl) => If(StartsWith(s, sub), Some <ushort>((ushort)current), IndexOf(tl, sub, current + 1)))); }
private static Zen <bool> Contains(Zen <IList <ushort> > s, Zen <IList <ushort> > sub) { return(s.Case( empty: sub.IsEmpty(), cons: (hd, tl) => OrIf(StartsWith(s, sub), Contains(tl, sub)))); }