SITCON
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- GA: UA-34467841-15 --- 宣告式編程風味模型化指令式編程程式碼 - 陳立凡 === <blockquote> 我真的想不太到適當的標題 QQ,不用太在意上面那個標題 (?) 在這場議程中,我會分享我於去年專研課所做的研究。研究中我用一些方式,在 Functional Programming 的框架下嚴格定義了日常我們看到的一些語法的行為,例如變數指定、if else、for loop 等。 我會盡量使用平易近人的方式講解,讓先備知識降到最低。 ## 先備知識 必備: 對程式語言有基礎了解者 (知道條件判斷、迴圈等) 有很好,沒有也沒關係:接觸過程式語言理論相關者 </blockquote> ###### tags: `SITCON 2020 共筆` `SITCON 2020` `2020` `共筆` `R3` {%hackmd dTfmj-h3QvSA0myqavKbxg %} > 請從這裡開始 ## About me telegram、FB、IG - koru1130 ## 研究背景 - 班上原來要做專研 - 將 IP 轉換成 FP - 原本想投科展 - 剛好遇到 CFP ## Programing Paradigm - Imperative - Declarative ## IP 與 FP - Imperative - 由指令所構成 - statement - 有狀態 - 變數可變 - Functional - 由函數所構成 - expression - 無狀態 - 變數不可變 ## Syntax & Semantic - Syntax 語法 - Semantic 語義 - 雙方括號 - [_] ## BNF 一種表示語法的方式 \<symbol\>::__expression__ \<symbol\> \<digit\> ::= 1|2|3|4|5|6|7|8|9|0 \<number\>::=\<digit\>|\<number\>\<digit\> - 3 - 42 \<expr\>::=\<number\> \<expr\>+\<expr\> \<expr\>-\<expr\> 15 1符合number5符合digit ## Function type - 參數 -> 函數值 - int add1(int x){...} - add1: int -> int 第一個參數->第二個參數->函數值 max: int -> int -> int max: int -> (int -> int) ## 對 IP 的另一種想像 S1: a <- 1 S2: b <- 2 S3: a <- a+b S3(S2(S1(st))) P:=O|S;P P 遞迴 [[\_]] Statement ->(State ->State) [[O]] st=st [[S;P]] st = ([[S]]。[[P]]) st ## Evaluate e:=v|a|f(e,e...e) v 值 a 變數 f(e,e...e) 函數呼叫 E:(Expression, State) -> Value E(v, st) = v E(a, st) = get a st E(f(e0, e1 ... en), st) = f(E(e1, st), E(e2,st) ... , E(en, st)) st = | | | | --- | --- | | | | ||| get : Name -> State -> Value get owo st = 3 ## Variable assignment S := a <- e [[a <- e]] st = set a E(e, st) st state set : name -> value ## if statement s := if e then s else s ifte(true,e1,e2) = e1 ifte(false, e1, e2) = e2 [[if c then s1 else s2]] st = ifte(E(c, st), [[s1]], [[s2]]) st ## for lop statement [[for i in ls do s]] st = (foldl(λf.x.([[s[i:=x]]]))) <!-- latex --> ## fold function fold : (a -> b -> a) ->a -> [b] -> a fold fz[1,2,3,4,5] fold (+) 0 [1,2,3,4,5] = ((((0 + 1) + 2) + 3) + 4) + 5 [[for i in ls do s]] st = (fold \_z ls) st z = id _ = λf . x . ([[s[i := x]]] 。 f) <!-- 放這 λ --> <!-- thx --> for i in ls do a <- a + i [[for i in ls do a <- g(a, i)]] st = [[a <- (foldl g a xs)]] st f(foldl g a xs) = foldl h b xs <= (f a=b) ^ (f (g x y) = h(f x)y) ### proof of theorem 2: ## reference ## Q&A 為什麼變數不可變 和一般語言有變數的概念不同,function 沒有變數的概念,不能更改它 所以 function programming 什麼時候會用到呢? 有什麼適合的程式語言支持嗎? React is function programming Haskell is function programming 為什麼會想到用 functional model imperative oop 也可以用 functional 遞迴啊 變數不可變 -> 只能遍歷 array 取值而已 他的概念是有點像 lisp 類型的語言嗎? Haskell 有什麽缺陷嗎? io 複雜 可以介紹你個人學習資訊的經歷嗎? [wiki](https://en.wikipedia.org/wiki/Fold_(higher-order_function)) 推坑 Haskell X) flolac 邏輯 語言與計算暑期研習營 偶數年 functional 奇數年 ...

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully