# 未定義是值嗎？

``````let yes = f => y => f();
let no = x => f => f();
let when = c => c;
``````

``````let pair = l => r => f => f(l)(r);
let left = p => p(l => _ => l);
let right = p => p(_ => r => r);

let nil = pair(undefined)(undefined);
let con = h => t => pair(h)(t);
let tail = right;
``````

`undefined` 是值嗎？或者只是個唯一的符號？`undefined` 表示沒有東西、也不是容器、沒有對應的操作，什麼也沒有？

``````let is_undefined = n => n === undefined ? yes : no;
``````

``````let undef = (_ => _)();
``````

``````let is_undef = n => n === undef ? yes : no;
``````

``````let pair = l => r => f => f(l)(r);
let left = p => p(l => _ => l);
let right = p => p(_ => r => r);

let nil = pair(undef)(undef);
let con = h => t => pair(h)(t);
let tail = right;
``````

``````let isEmpty = l => is_undef(head(l));
``````

``````let len = l => when(isEmpty(l))
(_ => 0)
(_ => 1 + len(tail(l)));

let sum = l => when(isEmpty(l))
(_ => 0)
``````

``````let rcon = t => h => when(is_undef(h))
(_ => t)
(_ => rcon(con(h)(t)));

let rev = r => l => when(isEmpty(l))
(_ => r)

let reverse = l => rev(nil)(l);

let elems = rcon(nil);

let list = es => reverse(es());
``````

``````let lt = list(elems(1)(2)(3)(4));
console.log(len(lt));    // 4
console.log(sum(lt));    // 10
``````

``````let map = l => f => when(isEmpty(l))
(_ => nil)
``````

``````let lt2 = map(list(elems(1)(2)(3)))(elem => elem - 1);
console.log(array(lt2));
``````

``````function array(lt) {
function arr(acc, l) {
if(isEmpty(l) === yes) {
return acc;
} else {