Simple toContinousPointSet
This commit is contained in:
		
							parent
							
								
									70664c0a91
								
							
						
					
					
						commit
						f49697b64a
					
				| 
						 | 
					@ -231,9 +231,8 @@ let doN = (n, fn) => {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let sample = (t: t): float => {
 | 
					let sample = (t: t): float => {
 | 
				
			||||||
  let randomItem = Random.float(1.)
 | 
					  let randomItem = Random.float(1.0)
 | 
				
			||||||
  let bar = t |> T.Integral.yToX(randomItem)
 | 
					  t |> T.Integral.yToX(randomItem)
 | 
				
			||||||
  bar
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let isFloat = (t: t) =>
 | 
					let isFloat = (t: t) =>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ module Wrappers = {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module Prepare = {
 | 
					module Prepare = {
 | 
				
			||||||
 | 
					  type t = frValue
 | 
				
			||||||
  type ts = array<frValue>
 | 
					  type ts = array<frValue>
 | 
				
			||||||
  type err = string
 | 
					  type err = string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,6 +27,14 @@ module Prepare = {
 | 
				
			||||||
        | _ => Error(impossibleError)
 | 
					        | _ => Error(impossibleError)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    module Array = {
 | 
				
			||||||
 | 
					      let openA = (inputs: t): result<ts, err> =>
 | 
				
			||||||
 | 
					        switch inputs {
 | 
				
			||||||
 | 
					        | FRValueArray(n) => Ok(n)
 | 
				
			||||||
 | 
					        | _ => Error(impossibleError)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  module ToValueTuple = {
 | 
					  module ToValueTuple = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,36 @@ module Declaration = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let registry = [
 | 
					let registry = [
 | 
				
			||||||
  Function.make(
 | 
					  Function.make(
 | 
				
			||||||
    ~name="FnMake",
 | 
					    ~name="toContinuousPointSet",
 | 
				
			||||||
 | 
					    ~definitions=[
 | 
				
			||||||
 | 
					      FnDefinition.make(
 | 
				
			||||||
 | 
					        ~name="toContinuousPointSet",
 | 
				
			||||||
 | 
					        ~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
 | 
				
			||||||
 | 
					        ~run=(inputs, _) => {
 | 
				
			||||||
 | 
					          let array = inputs->E.A.unsafe_get(0)->Prepare.ToValueArray.Array.openA
 | 
				
			||||||
 | 
					          let xyCoords =
 | 
				
			||||||
 | 
					            array->E.R.bind(xyCoords =>
 | 
				
			||||||
 | 
					              xyCoords
 | 
				
			||||||
 | 
					              ->E.A2.fmap(xyCoord =>
 | 
				
			||||||
 | 
					                [xyCoord]
 | 
				
			||||||
 | 
					                ->Prepare.ToValueArray.Record.twoArgs
 | 
				
			||||||
 | 
					                ->E.R.bind(Prepare.ToValueTuple.twoNumbers)
 | 
				
			||||||
 | 
					              )
 | 
				
			||||||
 | 
					              ->E.A.R.firstErrorOrOpen
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					          let expressionValue =
 | 
				
			||||||
 | 
					            xyCoords
 | 
				
			||||||
 | 
					            ->E.R.bind(r => r->XYShape.T.makeFromZipped->E.R2.errMap(XYShape.Error.toString))
 | 
				
			||||||
 | 
					            ->E.R2.fmap(r => ReducerInterface_ExpressionValue.EvDistribution(
 | 
				
			||||||
 | 
					              PointSet(Continuous(Continuous.make(r))),
 | 
				
			||||||
 | 
					            ))
 | 
				
			||||||
 | 
					          expressionValue
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					  ),
 | 
				
			||||||
 | 
					  Function.make(
 | 
				
			||||||
 | 
					    ~name="Declaration",
 | 
				
			||||||
    ~definitions=[
 | 
					    ~definitions=[
 | 
				
			||||||
      FnDefinition.make(~name="declareFn", ~inputs=[Declaration.frType], ~run=(inputs, _) => {
 | 
					      FnDefinition.make(~name="declareFn", ~inputs=[Declaration.frType], ~run=(inputs, _) => {
 | 
				
			||||||
        inputs->E.A.unsafe_get(0)->Declaration.fromExpressionValue
 | 
					        inputs->E.A.unsafe_get(0)->Declaration.fromExpressionValue
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -571,6 +571,7 @@ module A = {
 | 
				
			||||||
  let tail = Belt.Array.sliceToEnd(_, 1)
 | 
					  let tail = Belt.Array.sliceToEnd(_, 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let zip = Belt.Array.zip
 | 
					  let zip = Belt.Array.zip
 | 
				
			||||||
 | 
					  let unzip = Belt.Array.unzip
 | 
				
			||||||
  let zip3 = (a, b, c) =>
 | 
					  let zip3 = (a, b, c) =>
 | 
				
			||||||
    Belt.Array.zip(a, b)->Belt.Array.zip(c)->Belt.Array.map((((v1, v2), v3)) => (v1, v2, v3))
 | 
					    Belt.Array.zip(a, b)->Belt.Array.zip(c)->Belt.Array.map((((v1, v2), v3)) => (v1, v2, v3))
 | 
				
			||||||
  // This zips while taking the longest elements of each array.
 | 
					  // This zips while taking the longest elements of each array.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -148,6 +148,11 @@ module T = {
 | 
				
			||||||
    | None => Ok(attempt)
 | 
					    | None => Ok(attempt)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  let makeFromZipped = (values: array<(float, float)>) => {
 | 
				
			||||||
 | 
					    let (xs, ys) = E.A.unzip(values)
 | 
				
			||||||
 | 
					    make(~xs, ~ys)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module Ts = {
 | 
					module Ts = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user