duangsuse::Echo
709 subscribers
4.23K photos
127 videos
583 files
6.44K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
Forwarded from dnaugsuz
由一个不成立的条件得出某命题成立,然后再从那个成立的命题解出自己想要的答案……
上面也的确是循环定义,但从 statement 的开始来看,就已经有纰漏了,除非“鲁迅”会在你说出纰漏的时候强调一遍先读完后半部分。
你觉得面向对象四大特性,以什么顺序排列比较好?
Anonymous Poll
33%
封装、抽象、继承、多态
67%
封装、继承、抽象、多态
#Java 里 (&) 竟然不只是 bitwise and,还支持 boolean&boolean 的使用(只是不短路),真是……
Forwarded from dnaugsuz
🤔 一般人都会承认 (p1&&p2) || (p3&&p4) 这种直觉的吧
Forwarded from dnaugsuz
补充一句,(p && q) 短路的意思是若 p 不成立则 q 不执行
(p || q) 的短路则是若 p 已成立则 p 不执行
刷新了我的认知 #DontKnow
还有 #JavaScript , Promise 是 ES6, async/await 是 ES7 ……
#GitHub 竟然火了? 开始创建2h 的时候还是个空项目
Forwarded from せっせと的瞎吐槽👻
https://github.com/itorr/nbnhhsh

😩「能不能好好说话?」 拼音首字母缩写翻译工具
社交平台上通过拼音首字母缩写指代特定词句的情况越来越多,为了让常人勉强能理解这一门另类沟通方式、做了这一个划词翻译油猴脚本。
Forwarded from せっせと的瞎吐槽👻
#gui #rust #recommended https://github.com/hecrj/iced
🤔 啊!这个有意思! SMVU(State, Message, View logic, Update logic) 提纲得好!

应用的状态是 State,Message 可以触发改变它的逻辑
State 本身也需要 View 来渲染,State 改变了就需要 Update
🤔 #Rust 真是一个有新鲜血液的语言,虽然从特性上来看类型系统不好理解,但不得不说用于编程实践是完全没问题的
https://guide.elm-lang.org/ 好像 #Haskell 的语法啊 🤔 case of 还有等号函数定义、layout……
import Browser
import Dom.Widgets exposing (div, Text, Button)
import Dom.Events exposing (onClick)

main = Browser.sandbox { init = 0, view = view, update = update }
update state message =
case msg of
"inc" -> state + 1
else -> state
view state =
div [
Text ["$state"]
Button ["inc", "inc"]
]


🤔没看几眼就开始默写了,不会
duangsuse::Echo
import Browser import Dom.Widgets exposing (div, Text, Button) import Dom.Events exposing (onClick) main = Browser.sandbox { init = 0, view = view, update = update } update state message = case msg of "inc" -> state + 1 else -> state view state…
好了,我懂了。

import Browser
import Html exposing (Dom, div, button)
import Html.Events exposing (onClick)

type Msg = Increment | Decrement

main = Browser.sandbox { init = 0, view = view, update = update }

view model =
div [], [
([div [text model] ])
(button [text "+1"] [onClick Increment]),
(button [text "-1"] [onClick Decrement])
]

update msg model =
case msg of
Increment -> model + 1
Decrement -> model - 1
我觉得这一遍应该可以去试水了 🤔
module Main exposing (..)

import Browser
import Html exposing (Html, div, text, button)
import Html.Events exposing (onClick)

type alias Model = Int
type Msg = Increase | Decrease

main = Browser.sandbox { init = 0, view = view, update = update }

view model =
div []
[
div [] [text (String.fromInt model)],
button [onClick Decrease] [text "-1"],
button [onClick Increase] [text "+1"]
]

update msg model =
case msg of
Increase -> model + 1
Decrease -> model - 1


好了,没想到是这种参数顺序…… 我还以为 f [a 1] [b "?"] 是 "keyword argument" 呢

https://elm-lang.org/examples/buttons
duangsuse::Echo
我觉得这一遍应该可以去试水了 🤔 module Main exposing (..) import Browser import Html exposing (Html, div, text, button) import Html.Events exposing (onClick) type alias Model = Int type Msg = Increase | Decrease main = Browser.sandbox { init = 0, view = view, update =…
其实刚才我觉得 view 定义里,div 的参数列表的 layout 文法很复杂,说明 Elm 的语法实现起来很困难,不能不预取字符就判断是否开启新 layout 深度 🤔
刚才我才发现,只要参数列表不加逗号就是利用 layout 了,不过那还是需要先知道参数个数才能不预取字符。
duangsuse::Echo
我觉得这一遍应该可以去试水了 🤔 module Main exposing (..) import Browser import Html exposing (Html, div, text, button) import Html.Events exposing (onClick) type alias Model = Int type Msg = Increase | Decrease main = Browser.sandbox { init = 0, view = view, update =…
我再来复写下 Random die (1-6) :

module Main exposing (..)
import Browser
import Html exposing (Html, text, button)
import Html.Events (onClick)
import Random

type alias Model = { dieFace: Int }
type Msg = Roll | NewFace Int

view : Model -> Html Msg
view model =
div []
[
text (String.formInt mode.dieFace),
button [onClick Roll] [text "Roll"]
]

update: Msg -> Model -> (Model, Cmd)
update msg model =
case Msg of
Roll -> (model, Cmd.none)
(NewFace x) -> (Model { dieFace = x }, Random.rand dieFace (1..6))

subscriptors = Sub.none
duangsuse::Echo
我再来复写下 Random die (1-6) : module Main exposing (..) import Browser import Html exposing (Html, text, button) import Html.Events (onClick) import Random type alias Model = { dieFace: Int } type Msg = Roll | NewFace Int view : Model -> Html Msg view model…
……等等,不就是个 Effect 嘛,我又会了

module Main exposing (..)
import Browser
import Html exposing (Html, div, h1, text, button)
import Html.Events exposing (onClick)
import Random

type alias Model { dieFace: Int }
type Msg = Roll | NewFace Int

view model =
div []
[
h1 [] [text (String.fromInt mode.dieFace)],
button [onClick Roll] [text "Roll"]
]
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
Roll -> (model, Random.rand (1..6))
(NewFace x) -> (Model x, Cmd.none)

subscription = Sub.none
import Browser
import Html exposing (..)
import Html.Events exposing (onClick)
import Random

type alias Model = { dieFace: Int }
type Msg = Roll | NewFace Int

main = Browser.element { init = init, view = view, update = update, subscriptions = subscriptions }

init : () -> (Model, Cmd Msg)
init _ = (Model 0, Cmd.none)

view : Model -> Html Msg
view model =
div []
[
h1 [] [text (String.fromInt model.dieFace)],
button [onClick Roll] [text "Roll"]
]

update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
Roll -> (model, Random.generate NewFace (Random.int 1 6))
(NewFace x) -> (Model x, Cmd.none)

subscriptions : Model -> Sub Msg
subscriptions model = Sub.none
https://elm-lang.org/examples/cat-gifs
很有意思,所有的视图更新都是在 update 里完成的,Message 则同时负责把数据送至 update 函数
State 都是 immutable 的,这样虽然会造成一些复杂性,但总体来看对程序的简洁性和规范性有很大帮助