moduleRSAGL.Math.ListUtils(doubles,loopedDoubles,consecutives,loopedConsecutives,zeroToOne)whereimportRSAGL.Math.TypesimportDebug.Trace-- | Transforms a list to a list of adjacent elements.---- @doubles [1,2,3,4,5] = [(1,2),(2,3),(3,4),(4,5)]@doubles::[a]->[(a,a)]doubles[]=[]doubles[_]=[]doubles(x:y:zs)=(x,y):doubles(y:zs)-- | loopedDoubles transforms a list to a list of adjacent elements, looping-- back to the beginning of the list.---- @loopedRSdoubles [1,2,3,4,5] = [(1,2),(2,3),(3,4),(4,5),(5,1)]@loopedDoubles::[a]->[(a,a)]loopedDoublesas=loopedDoubles_(headas)aswhereloopedDoubles__[]=[]loopedDoubles_a[x]=[(x,a)]loopedDoubles_a(x:y:zs)=(x,y):loopedDoubles_a(y:zs)-- | Answers a list containing every sequence of n consecutive-- elements in the parameter.---- @consecutives 3 [1,2,3,4] = [[1,2,3],[2,3,4]]@consecutives::Int->[a]->[[a]]consecutivesnxs=lettaken=takenxsinif(lengthtaken==n)then(taken:(consecutivesn$tailxs))else[]-- | Answers a list containing every sequence of n consecutive-- elements in the parameter, looping back to the beginning of the list.---- @consecutives 3 [1,2,3,4] = [[1,2,3],[2,3,4],[3,4,1],[4,1,2]]@loopedConsecutives::Int->[a]->[[a]]loopedConsecutivesnxs=consecutivesn$take(n+lengthxs-1)$cyclexs-- | Creates a list of numbers from 0.0 to 1.0, using n steps.-- This can't be done with the enum-from-to method, due to roundoff errors.zeroToOne::Integer->[RSdouble]zeroToOnen|n>100000=trace("Warning: zeroToOne was asked for "++shown++" subdivisions, which seems high. Using 100,000 instead.")zeroToOne100000zeroToOnen=map(*x)[0..(fromInteger$n-1)]wherex=recip(fromInteger$n-1)