Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"ReferenceError: list is not defined": The outside variable cannot be used/recognized during mapping. #228

Open
@zhengger

Description

@zhengger

I want to push value to variable list during mapping. It ends in the error "ReferenceError: list is not defined".
I'm using typescript and below is my code.

importParallelfrom'paralleljs';import{performance}from"perf_hooks";import*as_from"lodash";constl=_.range(10,20);constp=newParallel(l);constlog=function(){console.log(arguments);};constcurrent_encode_Time_before=performance.now();// One gotcha: anonymous functions cannot be serialzed// If you want to do recursion, make sure the function// is named appropriatelyconstlist:Array<number>=[];// I want to push new value to list during mappingfunctionfib(n:number):number{letnum:number=0;num=n<2 ?1 :fib(n-1)+fib(n-2);list.push(num);returnnum;};p.map(fib).then(()=>{constcurrent_encode_Time_later=performance.now();console.log("Parra: Test_Time difference",(current_encode_Time_later-current_encode_Time_before)/1000);});

The error is:

ReferenceError: list is not defined    at fib (eval at <anonymous> (/Users/zhen/dev/simple/node_modules/_paralleljs@1.1.0@paralleljs/lib/eval.js:7:5), <anonymous>:4:5)

Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp