Truly declarative language?

后端 未结 19 2242
梦毁少年i
梦毁少年i 2021-02-04 01:26

Does anyone know of a truly declarative language? The behavior I\'m looking for is kind of what Excel does, where I can define variables and formulas, and have the formula\'s re

19条回答
  •  南笙
    南笙 (楼主)
    2021-02-04 02:02

    react is an OCaml frp library. Contrary to naive emulations with closures it will recalculate values only when needed

            Objective Caml version 3.11.2
    
    # #use "topfind";;
    # #require "react";;
    # open React;;
    # let (x,setx) = S.create 10;;
    val x : int React.signal = 
    val setx : int -> unit = 
    # let (y,sety) = S.create 20;;
    val y : int React.signal = 
    val sety : int -> unit = 
    # let z = S.Int.(+) x y;;
    val z : int React.signal = 
    # S.value z;;
    - : int = 30
    # setx 50;;
    - : unit = ()
    # S.value z;;
    - : int = 70
    

提交回复
热议问题