Live Note

Remain optimistic

What is currying

Currying is the technique of translating the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single argument. -- Wikipedia
It mean this:

1
2
3
4
5
let add = (x) => (y) => x + y
let addOne = add(1)
let addTwo = add(2)
addOne(11) // 12
addTwo(11) // 13

In order to define functions more easily, we need the loadsh, it will help us to currying the function.

make some using thing

1
2
3
4
5
6
7
8
9
10
11
12
13
var _ = require("loadsh").curry

var match = _((regex, str) => str.match(regex))
var replace = _((regex, replacement, str) => str.replace(regex, replacement))
var filter = _((f, array) => array.filter(f))
match(/\s+/g, "test Message") // [' ']
match(/\s+/g)("test Message") // [' ']

var hasSpace = match(/\s+/g)
hasSpace("testMessage") // null
filter(hasSpace, ["testMessage1", "test Message2", "test Message 3"]) // ['test Message2', 'test Message 3']
var noA = replace(/[Aa]+/g, "*")
noA("aaaabbbAAAc") // '*bbb*c'
Read more »

TikTok

川普不对伊朗动武 美股涨 金价回落 油价跳水

伊朗袭击美军驻伊拉克基地后,美国总统川普表示将升级经济制裁取代付诸武力。市场乐观情绪上扬,美股上涨,金价回落,油价则大跳水。

川普 1 月 8 日在白宫发表谈话,伊朗袭击并未伤害到任何美国人,称伊朗有所退让,暗示不会对伊朗动武,伊朗外交部长也称该国不寻求升级事态,这些消息都缓解了投资人对美伊局势的不安。

8 日美国股市上涨,道琼工业指数收涨 161.41 点或 0.56%,报 28745.09 点。标普 500 指数收涨 15.87 点或 0.49%,报 3253.05 点。那斯达克指数收涨 60.66 点或 0.67%,报 9129.24 点。费城半导体指数上涨 0.31 点或 0.02%,报 1867.59 点。

那斯达克指数创收盘新高,道琼工业指数、标普 500 指数、费城半导体指数徘回历史次高位。

Read more »

Classes

1
2
3
4
5
6
7
8
9
10
11
class Greeter {
greeting: string

constructor(message: string) {
this.greeting = message
}

greet(): string {
return "Hello, " + this.greeting
}
}

Private

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Animal {
constructor(private name: string) {}
}

class Horse extends Animal {
constructor() {
super("Horse")
}
}

class Human {
constructor(private name: string) {}
}

let animal = new Animal("Lucy")
let horse = new Horse()
let human = new Human("Jack")
animal = horse // success
animal = human // failed
Read more »

在 TypeScript 的类型系统中,Top Type(顶层类型)Bottom Type(底层类型) 是两个非常重要的概念。它们分别代表了类型范围的“最顶层”和“最底层”,理解它们对于掌握 TypeScript 的类型系统至关重要。

Read more »