public HKT <ListHKT, B> Map <A, B>(Func <A, B> f, HKT <ListHKT, A> a) { List <A> aList = ListHKT <A> .Narrow(a).value; B[] result = new B[aList.Count]; for (int i = 0; i < aList.Count; i++) { result[i] = f(aList[i]); } return(new ListHKT <B>(new List <B>(result))); }
void Awake() { /* * Generate initial wave height field (h0k h0minusk) textures */ h0k = new H0K(N, L, amplitude, windSpeed, capillarSupressFactor, direction, noiseTexture1, noiseTexture2, noiseTexture3, noiseTexture4, h0kComputeShader); h0k.Run(); /* * Generate twiddle factors texture */ twiddleFactors = new TwiddleFactors(N, twiddleFactorsComputeShader); twiddleFactors.Run(); /* * Generate wave height field textures at time t (dx/dy/dz displacement) */ hkt = new HKT(N, L, T, ConvertToTexture2D(h0k.h0kOutputRenderTexture, N), ConvertToTexture2D(h0k.h0minuskOutputRenderTexture, N), hktComputeShader); hkt.Run(); outputMaterial.mainTexture = hkt.dyDisplacementOutputRenderTexture; }
public HKT <State <S>, B> FlatMap <A, B>(HKT <State <S>, A> a, Func <A, HKT <State <S>, B> > f) =>
public HKT <ListHKT, B> Map <A, B>(Func <A, B> f, HKT <ListHKT, A> a) => new ListHKT <B>(new List <B>( ListHKT <A> .Narrow(a).value.Select(f)));
public HKT <Maybe, B> FlatMap <A, B>(HKT <Maybe, A> a, Func <A, HKT <Maybe, B> > f) { A value = ((Just <A>)Maybe <A> .Narrow(a)).value; return(value == null ? new Nothing <B>() : f(value)); }
public HKT <ListHKT, B> FlatMap <A, B>(HKT <ListHKT, A> a, Func <A, HKT <ListHKT, B> > f) => ListHKT <A> .Narrow(a).value.Aggregate(new ListHKT <B>(), (result, ele) => { result.value.AddRange(ListHKT <B> .Narrow(f(ele)).value); return(result); });