# python
> (_, _, x) = [1, 2, 3] # not with len > 3
> x
3// js
> (([head, ...tail]) => tail.concat(head))([1, 2, 3, 4, 5])# python
> (_, _, x) = [1, 2, 3] # not with len > 3
> x
3// js
> (([head, ...tail]) => tail.concat(head))([1, 2, 3, 4, 5])# python
> print (lambda _: _.format(_))('+{}+')
"++{}++"
> print "{a} and {b}".format(b = 'b', a = 'a')
"a and b"// js
//***************************************************************************
// USE CASE
//
// SUM first 100 even integers
//***************************************************************************
n = [...Array(100).keys()] // get indexes starting at 0// js
> ((x, y) => (w => w + x + y)(0))(1, 2)
3# python
> print (lambda x, y: (lambda w : w + x + y)(0))(1, 2)
3| > [{a:1}, {b:2}, {c:3}].reduce((acc, o) => {return Object.assign(acc, o)}, {}) | |
| {a: 1, b: 2, c: 3} | |
| > e = {a: 1} | |
| > e = {...e, b: 1} | |
| {a: 1, b: 2} | |
| // Creating object attributes with names of array elements | |
| > arr = ['a', 'b', 'c'] | |
| > Object.assign(...arr.map((attr, index) => {return {[attr]: index}}), {}) |
| > [1, 2, 3].map((_, e) => {return {[e]:e}}) // or simply e => ... | |
| [{…}, {…}, {…}] | |
| 0: {1: 1} | |
| 1: {2: 2} | |
| 2: {3: 3} | |
| > a = {b: {c: {}}} | |
| > a.b.c["d"] = a | |
| > a | |
| b: |
| db.system.js.save({ | |
| _id: 'prt' | |
| , value: (...args) => { | |
| args.forEach(arg => | |
| printjson({ [arg[0] + '_COMP_ATTR_NAME']: 0 }) | |
| ) | |
| } | |
| }) | |
| //********************************************* |
| db.system.js.save({ | |
| _id: 'prt' | |
| , value: (...args) => { | |
| args.forEach(arg => | |
| printjson(arg) | |
| ) | |
| } | |
| }) | |
| // ****************************************** |
// js NONE-- haskell
> sum [x | x <- [1..10]]| if ((var as = Item.GetValue(TAXA_FIXA_IRS)) == "Sim") | |
| { | |
| SetValueAndVisible(tbcpercentagemirs, PERCENTAGEM_IRS, WebControlType.TableCell); | |
| } |