def double(x):
    return x * 2



def sample():
    return 1, 2


sample() 
a, b = sample()  



function double(x) {
    return x * 2;
}



function sample() {
    return [1, 2];
}

const [a, b] = sample();  



function sample2() {
    return 1, 2;
}



def show(x=1, y=2):
    print(f"x is {x}, y is {y}")



show()  



show(x=10)  



show(10)  
show(10, 100)  



def show2(x):
    print(f"x is {x}")


show2(1)  



def show2(x, y):
    print(f"x is {x}, y is {y}")


show2(1) 



def show2(x, y=2):
    print(f"x is {x}, y is {y}")


show2(1)  



def show2(x, y=2, z): 
    print(f"x is {x}, y is {y}, z is {z}")



def append_one(lst=[]):
    lst.append(1)
    return lst



append_one() 



def append_one(lst=None):
    if lst is None: lst = []
    lst.append(1)
    return lst


append_one() 
append_one() 



def show(x, y):
    print(f"x is {x}, y is {y}")


show(1, 2) 



show(x=1, y=2) 



show(y=2, x=1)



show(1, y=2) 



def intro(name, area, hobby, comment):
    print(f"私は{name}です。{area}出身で、趣味は{hobb}です。{comment}。")



intro("カオル", "川崎", "スポーツ", "よろしくです")



intro("カオル", "スポーツ", "川崎", "よろしくです")



intro(name="カオル", area="川崎", hobby="スポーツ", comment="よろしくです")



def show(x, *, y):
    print(f"x is {x}, y is {y}")


show(1, 2) 
show(1, y=2) 



def show(x, /, y):
    print(f"x is {x}, y is {y}")


show(x=1, 2) 
show(1, 2) 



def show(x, *ys):
    print(f"x is {x}, ys is {ys}")


show(1) 
show(1, 2, 3) 



show(1, (2, 3))



show(1, *(2, 3))



show(1, 2, 3)



show(1, ys=(2, 3))



def test(x, **ys):
    print(ys)


test(1, a=2, b=3) 



def show(x, *ys, z):
    print(f"x is {x}, ys is {ys}, z is {z}")


show(1, 2, 3, 4) 
show(1, 2, 3, z=4) 



function show(x, y) {
    console.log(`x is ${x}, y is ${y}`);
}

show(1, 2); 
show(1, 2, 3); 
show(1); 



function showArgs() {
    console.log(`length of arguments is ${arguments.length}`);
    console.log(`first is ${arguments[0]}, second is ${arguments[1]}`);
}

showArgs(10, 20); 
showArgs(10, 20, 30); 
showArgs(10); 



function show(x = 1, y = 2) {
    console.log(`x is ${x}, y is ${y}`);
}

show(); 



function appendOne(array = []) {
    array.push(1);
    return array;
}

appendOne(); 
appendOne(); 



show(1, undefined); 



show(1, null); 



function showKeywordArgs({x, y}) {
    console.log(`x is ${x}, y is ${y}`);
}

showKeywordArgs({x: 1, y: 2}); 



function showKeywordArgs({x = 1, y}) {
    console.log(`x is ${x}, y is ${y}`);
}

showKeywordArgs(); 
showKeywordArgs({ y: 2 }); 



showKeywordArgs({ z: 2 }); 



function show(x, ...ys) {
    console.log(`x is ${x}, ys is ${ys}, length of ys is ${ys.length}`);
}

show(1, 2, 3); 



show(1, [2, 3]); 



show(1, ...[2, 3]); 



show(1, ...[2, 3], 4); 



def sample():
    print("hello")


say = sample 
say() 

function sample() { console.log("hello"); }

const say = sample;
say(); 



len([1, 2]) 
len = 1
len([1, 2]) 



const show = function(x) {
    console.log(`x is ${x}`);
}

show(1); 



const double = (x) => {
    return x * 2;
}

double(10); 



const double = x => x * 2;

double(10); 



const x = [1, 2];
x.indexOf(2);



function showThis() { console.log(this); }

showThis(); 
showThis.call(1); 
showThis.apply(1); 



function sample(x, y) {
    console.log(`x is ${x}, y is ${y}`);
}

sample.call(null, 1, 2); 
sample.apply(null, [1, 2]); 



double = lambda x : x * 2
double(2) 



say = lambda : print("hello")
say() 



function doubleMap(arr) {
    const newArr = [];
    for (const v of arr) {
        newArr.push(v * 2);
    }
    return newArr;
}

doubleMap([1, 2]); 



function strLengthMap(arr) {
    const newArr = [];
    for (const v of arr) {
        newArr.push(v.length);
    }
    return newArr;
}

strLengthMap(["a", "bcd"]); 



function myMap(arr) {
    const newArr = [];
    for (const v of arr) {
        newArr.push(「何らかの処理」);
    }
    return newArr;
}



function myMap(arr, fnc) {
    const newArr = [];
    for (const v of arr) {
        newArr.push(fnc(v));
    }
    return newArr;
}



function doubleFnc(x) {
    return x * 2;
}

myMap([1, 2, 3], doubleFnc); 



myMap([1, 2, 3], x => x * 2); 
