From 4d1f76f80e0b11f5202d984c73ec2a2506cdceea Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Fri, 9 Sep 2022 14:39:42 +0400 Subject: [PATCH] slightly faster map implementation see this comment: https://github.com/quantified-uncertainty/squiggle/pull/1047#issuecomment-1241805927 --- .../src/rescript/FunctionRegistry/Library/FR_List.res | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res index 1def1e36..7be0f9f3 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res @@ -33,16 +33,14 @@ module Internals = { eLambdaValue, reducer: ProjectReducerFnT.t, ): ReducerInterface_InternalExpressionValue.t => { - let mappedList = array->E.A.reduceReverse(list{}, (acc, elem) => { - let newElem = Reducer_Expression_Lambda.doLambdaCall( + Belt.Array.map(array, elem => + Reducer_Expression_Lambda.doLambdaCall( eLambdaValue, list{elem}, (accessors: ProjectAccessorsT.t), (reducer: ProjectReducerFnT.t), ) - list{newElem, ...acc} - }) - mappedList->Belt.List.toArray->Wrappers.evArray + )->Wrappers.evArray } let reduce = (