Comment

Comment by wryl

It's a general purpose programming language who's main paradigm is rule-based pattern matching.

A sample.

  <> (-- ?x) ()
  -- (Now we can add comments to what we are doing.)
  -- (Let's add some alternative syntax for defining rules.)
  <> (?x -> ?y) (<> ?x ?y)

  -- (Let's add some boolean operators, 'and' and 'or'.)
  ((true)  && (true))  -> true
  ((true)  && (false)) -> false
  ((false) && (true))  -> false
  ((false) && (false)) -> false

  ((true)  || (true))  -> true
  ((true)  || (false)) -> true
  ((false) || (true))  -> true
  ((false) || (false)) -> false

  -- (Some alternative syntax.)
  (?x and ?y) -> (?x && ?y)
  (?x or ?y)  -> (?x || ?y)

  -- (Let's build an 'if' statement.)
  (quote ?x)    -> (quote ?x)
  (unwrap (?x)) -> (unwrap ?x)
  (unwrap ?x)   -> ?x
  (
    if ?c
      ?t
    else
      ?f
  ) -> (
    if/else ?c
      quote ?t
      quote ?f
  )
  (
    if/else (true)
      quote ?t
      quote ?f
  ) -> (
    unwrap ?t
  )
  (
    if/else (false)
      quote ?t
      quote ?f
  ) -> (
    unwrap ?f
  )

  -- (All together.)
  if ((true) and ((false) or (true))) (
    Hooray!
  ) else (
    Boo!
  )
parent wryl 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton