记忆力太差
module Main (..) where
import Browser
import Html exposing (Div, text, Button)
import Html.Events exposing (KeyUp)
import Random
type Dice = { newFace: Int }
type Message = Dice | NewFace Int
view d =
Div [], [
Button [KeyUp Dice], []
]
update d m =
case m of
Dice -> (d, Random.run (randint 0 2) )
(NewFace x) -> (Dict { newFace = x }, Cmd.none)
main = Browser.element { init = Dice { newFace = 0 }, view = view, update = update }
duangsuse::Echo
记忆力太差 module Main (..) where import Browser import Html exposing (Div, text, Button) import Html.Events exposing (KeyUp) import Random type Dice = { newFace: Int } type Message = Dice | NewFace Int view d = Div [], [ Button [KeyUp Dice], [] ] update…
刚才我在 online editor 上在线默写学习,就快要成功的时候,忍不住偷看了一下,结果给 Firefox 卡死了…… 两次……
不过算是已经了解了,
不过算是已经了解了,
init : () -> (Message, Cmd a) 的事实, subscriptions : () -> ??? 呢?🤔 ParserKt 里需要定义一个辅助的 sealed class Eiter<A, B> { data class Left, Right }
Left/Right 都持有
Left/Right 都持有
val value 整个 Either,我计划提供 val left: A?, right: B?
fun mustLeft():A, mustRight():B
fun <T, R> map(transform: (T) -> R): Either<R, R> where A: T, B: T (存疑?)fun <R> fold(trans_left: (A) -> R, trans_right: (B) -> R): RForwarded from 螺莉莉的黑板报
https://microsoftedge.microsoft.com/addons/detail/hokifickgkhplphjiodbggjmoafhignh
【本报讯】微软发布了 Grammarly 的竞品 Microsoft Editor,所有用户均可免费使用基本功能,M365(O365)用户可以使用高阶功能。
【本报讯】微软发布了 Grammarly 的竞品 Microsoft Editor,所有用户均可免费使用基本功能,M365(O365)用户可以使用高阶功能。
Forwarded from 一碗脑脊液。
2010 年 3 月 23 日,谷歌中国发表声明退出国内市场
2010 年 3 月 30 日,中国政府正式通过 DNS 污染等官方手段 封杀其所有域名及相关服务
=
2020 年 3 月 30日,十年。
2010 年 3 月 30 日,中国政府正式通过 DNS 污染等官方手段 封杀其所有域名及相关服务
=
2020 年 3 月 30日,十年。
我又要继续写关系式求解器了……
首先来看看 six primitives : State, Variable, Introduce
然后 Equal, Both, Either
那么怎么对 unification 进行可扩展的建模呢…… 先写点东西
首先来看看 six primitives : State, Variable, Introduce
然后 Equal, Both, Either
那么怎么对 unification 进行可扩展的建模呢…… 先写点东西
sealed class Either<A, B> {
data class Left<A>(val value: A): Either<A, Nothing>()
data class Right<B>(val value: B): Either<Nothing, B>()
val left: A? get() = (this as? Left<A>)?.value
val right: B? get() = (this as? Right<B>)?.value
fun mustLeft() = left ?: throw AssertionError("$this not left")
fun mustRight() = right ?: throw AssertionError("$this not right")
fun <R> fold(trans_left: (A) -> R, trans_right: (B) -> R): R = when (this) {
is Left -> trans_left(this.value)
is Right -> trans_right(this.value)
}
}https://mohu.pincong.rocks/question/
🤔 最近膜乎的链接都过期了,有简单的等价链接,我找不到合理的 URL replace Firefox 插件,自己写一个去。
🤔我简直是变态…… 为什么要写 format()……
🤔 最近膜乎的链接都过期了,有简单的等价链接,我找不到合理的 URL replace Firefox 插件,自己写一个去。
function onLink(url) {
for (let [pat, dst] of settings.replaceMap) {
let match = pat.exec(url);
if (match != null) { redirect(format(dst, i => match[i])); }
}
}
function drop(n, str) { return str.substring(n, str.length); }
function format(str, replace, prefix = '\\', take = view => /(\d+)/y.exec(view)[1], transform = Number.parseInt) {
let view = str;
let replaced = [];
while (view.length > 0) {
if (view.startsWith(prefix)) {
let took = take(view);
view = drop(took.length, view);
replaced.push( replace(transform(took)) );
} else {
let prefixIdx = view.indexOf(prefix);
if (prefixIdx == (-1)) prefixIdx = view.length;
replaced.push( view.substring(0, prefixIdx) );
view = drop(prefixIdx, view);
}
}
return replaced.join("");
} 🤔我简直是变态…… 为什么要写 format()……
function drop(n, str) { return str.substring(n, str.length); }
function format(str, replace, prefix = '\\' , take = view => /(\d+)/.exec(view)[0], transform = Number.parseInt) {
let view = str;
let result = [];
while (view.length != 0) {
let prefixIdx = view.indexOf(prefix); if (prefixIdx == (-1)) break;
result.push( view.substring(0, prefixIdx) );
view = drop(prefixIdx+prefix.length, view);
let took = take(view);
if (took == null) throw SyntaxError(`Unexpected ${view} after ${prefix}`);
result.push( replace(transform(took)) );
view = drop(took.length, view);
}
result.push(view);
return result.join("");
}