Forwarded from dnaugsuz
由一个不成立的条件得出某命题成立,然后再从那个成立的命题解出自己想要的答案……
上面也的确是循环定义,但从 statement 的开始来看,就已经有纰漏了,除非“鲁迅”会在你说出纰漏的时候强调一遍先读完后半部分。
上面也的确是循环定义,但从 statement 的开始来看,就已经有纰漏了,除非“鲁迅”会在你说出纰漏的时候强调一遍先读完后半部分。
#Java 里 (&) 竟然不只是 bitwise and,还支持 boolean&boolean 的使用(只是不短路),真是……
Forwarded from dnaugsuz
补充一句,(p && q) 短路的意思是若 p 不成立则 q 不执行
(p || q) 的短路则是若 p 已成立则 p 不执行
(p || q) 的短路则是若 p 已成立则 p 不执行
Forwarded from せっせと的瞎吐槽👻
https://github.com/itorr/nbnhhsh
😩「能不能好好说话?」 拼音首字母缩写翻译工具
社交平台上通过拼音首字母缩写指代特定词句的情况越来越多,为了让常人勉强能理解这一门另类沟通方式、做了这一个划词翻译油猴脚本。
😩「能不能好好说话?」 拼音首字母缩写翻译工具
社交平台上通过拼音首字母缩写指代特定词句的情况越来越多,为了让常人勉强能理解这一门另类沟通方式、做了这一个划词翻译油猴脚本。
GitHub
GitHub - itorr/nbnhhsh: 😩「能不能好好说话?」 拼音首字母缩写翻译工具
😩「能不能好好说话?」 拼音首字母缩写翻译工具. Contribute to itorr/nbnhhsh development by creating an account on GitHub.
Forwarded from せっせと的瞎吐槽👻
#gui #rust #recommended https://github.com/hecrj/iced
🤔 啊!这个有意思! SMVU(State, Message, View logic, Update logic) 提纲得好!
应用的状态是 State,Message 可以触发改变它的逻辑
State 本身也需要 View 来渲染,State 改变了就需要 Update
🤔 啊!这个有意思! SMVU(State, Message, View logic, Update logic) 提纲得好!
应用的状态是 State,Message 可以触发改变它的逻辑
State 本身也需要 View 来渲染,State 改变了就需要 Update
GitHub
GitHub - iced-rs/iced: A cross-platform GUI library for Rust, inspired by Elm
A cross-platform GUI library for Rust, inspired by Elm - iced-rs/iced
https://guide.elm-lang.org/ 好像 #Haskell 的语法啊 🤔 case of 还有等号函数定义、layout……
guide.elm-lang.org
Introduction · An Introduction to Elm
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我觉得这一遍应该可以去试水了 🤔
好了,没想到是这种参数顺序…… 我还以为
https://elm-lang.org/examples/buttons
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 =…
其实刚才我觉得
刚才我才发现,只要参数列表不加逗号就是利用 layout 了,不过那还是需要先知道参数个数才能不预取字符。
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.noneimport 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.nonehttps://elm-lang.org/examples/cat-gifs
很有意思,所有的视图更新都是在 update 里完成的,Message 则同时负责把数据送至 update 函数
State 都是 immutable 的,这样虽然会造成一些复杂性,但总体来看对程序的简洁性和规范性有很大帮助
很有意思,所有的视图更新都是在 update 里完成的,Message 则同时负责把数据送至 update 函数
State 都是 immutable 的,这样虽然会造成一些复杂性,但总体来看对程序的简洁性和规范性有很大帮助