Add a block to reverse a list (#844)

This commit is contained in:
Tim Dawborn
2017-01-22 05:48:42 +11:00
committed by Andrew n marshall
parent f6168e1364
commit 46316c7cea
12 changed files with 240 additions and 1 deletions

View File

@@ -353,3 +353,11 @@ Blockly.Python['lists_split'] = function(block) {
}
return [code, Blockly.Python.ORDER_FUNCTION_CALL];
};
Blockly.Python['lists_reverse'] = function(block) {
// Block for reversing a list.
var list = Blockly.Python.valueToCode(block, 'LIST',
Blockly.Python.ORDER_NONE) || '[]';
var code = 'list(reversed(' + list + '))';
return [code, Blockly.Python.ORDER_FUNCTION_CALL];
};