TranscryptOrg / Transcrypt

Python 3.9 to JavaScript compiler - Lean, fast, open!
https://www.transcrypt.org
Apache License 2.0
2.82k stars 215 forks source link

Python built-in map() to support more than one iterable #862

Open Jeroendevr opened 9 months ago

Jeroendevr commented 9 months ago

Currently the map() built in function is well supported, however it only works when passing one iterable. When passing two iterables the iterable result is null

Excpects

words = ("bike", "steer")

def func_1(prin):
    print(prin[0])

def func3(prin):
    print(prin[3])

function = (func_1, func3)

def apply(func: callable, word):
    func(word)

mapped = map(apply, function, words)

for x in mapped:
    x

---
b
e

Reality

null
null
JennaSys commented 4 days ago

The way map is implemented right now, it only accepts a single iterable. But I'll take a look at expanding that to match CPython behavior.

JennaSys commented 4 days ago

The new implementation of map should work correctly once v3.9.3 is deployed (currently it's only on the dev branch). Though, the variable function in the above example should be changed to functions so as not to confuse the JavaScript side of things.