Skip to content

Commit fdf551a

Browse files
committed
Convert list comprehension to #map
1 parent dcdcc4c commit fdf551a

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A restricted Python to idiomatic JavaScript / Ruby / Go / C# translator
77

88
[Pseudo](https://github.com/alehander42/pseudo) is a framework for high level code generation: it is used by this compiler to translate a subset of Python to all Pseudo-supported languages
99

10-
**If you are using Python3.5 and you experience problems with an already installed version of pseudo-python, please upgrade it to `0.2.12s` (`pip3 install pseudo-python --upgrade`)**
10+
**If you are using Python3.5 and you experience problems with an already installed version of pseudo-python, please upgrade it to `0.2.14` (`pip3 install pseudo-python --upgrade`)**
1111

1212

1313

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.12
1+
0.2.14

pseudo_python/ast_translator.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,8 +1415,31 @@ def _translate_listcomp(self, generators, elt, location):
14151415

14161416
sketchup['type'] = 'standard_iterable_call' + sketchup['type']
14171417

1418+
14181419
if not generators[0].ifs:
1419-
sketchup['function'] = 'map'
1420+
if 'index' not in sketchup and self._general_type(sketchup['sequences']['type']) == 'for_sequence':
1421+
elt = self._translate_node(elt)
1422+
return {
1423+
'type': 'standard_method_call',
1424+
'receiver': sketchup['sequences']['sequence'],
1425+
'message': 'map',
1426+
'args': [{
1427+
'type': 'anonymous_function',
1428+
'params': [sketchup['iterators']['iterator']],
1429+
'pseudo_type': ['Function', sketchup['iterators']['iterator']['pseudo_type'],
1430+
elt['pseudo_type']],
1431+
'return_type': elt['pseudo_type'],
1432+
'block': [{
1433+
'type': 'implicit_return',
1434+
'value': elt,
1435+
'pseudo_type': elt['pseudo_type']
1436+
}]
1437+
}],
1438+
'pseudo_type': ['List', elt['pseudo_type']]
1439+
}
1440+
1441+
else:
1442+
sketchup['function'] = 'map'
14201443
else:
14211444
test_node = self._testable(self._translate_node(generators[0].ifs[0]))
14221445
sketchup['function'] = 'filter_map'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='pseudo-python',
5-
version='0.2.12',
5+
version='0.2.14',
66
description='a python3 to pseudo compiler',
77
author='Alexander Ivanov',
88
author_email='alehander42@gmail.com',

0 commit comments

Comments
 (0)