Git Product home page Git Product logo

silly-actor's Introduction

silly-actor

Build Status

Examples

Example: 01

(system
  ((init Main ()))
  (define (Main) (Init (output (state)))))

Output

(())

Example: 02

(system
  ((init Main ()))
  (define (Main) (_ (seq (output 1) (output 2)))))

Output

((number . 1) (number . 2))

Example: 03

(system
  ((init Main 7))
  (define (Main) (_ (output (state)))))

Output

((number . 7))

Example: 04

(system
  ((init Main ()))
  (define (Main) (8 (output success)) (_ (send (self) 8))))

Output

((atom . success))

Example: 05

(system
  ((init Main ()))
  (define (Main)
    (_ (seq (send (self) 8)
            (become (actor (8 (output success))) (state))))))

Output

((atom . success))

Example: 06

(system
  ((init Main ()))
  (define (Aux) (7 (output (state))) (_ ()))
  (define (Main)
    (_ (let ([Id (spawn Aux success)]) (send Id 7)))))

Output

((atom . success))

Example: 07

(system
  ((init Main ()))
  (define (Aux) (7 (output (state))) (_ ()))
  (define (Main) (_ (send (spawn Aux success) 7))))

Output

((atom . success))

Example: 08

(system
  ((init Main ()))
  (define (Main)
    (_ (let ([X 7]) (match 7 ['X (output success)])))))

Output

((atom . success))

Example: 09

(system
  ((init Main ()))
  (define (Main) (_ (match '(1 2) [(X _) (output X)]))))

Output

((number . 1))

Example: 10

(system
  ((init Main ()))
  (define (Aux) (7 (reply 8)) (_ ()))
  (define (Main)
    (_ (seq (send (spawn Aux ()) 7)
            (output (recv (8 success)))))))

Output

((atom . success))

Example: 11

(system
  ((init Main ()))
  (define (Aux)
    (7 (seq (reply 8) (reply 13)))
    (9 (reply 10))
    (_ ()))
  (define (Main)
    (_ (let ([Id (spawn Aux ())])
         (seq (output (call Id 7 (8 a)))
              (output (call Id 9 (10 b))))))))

Output

((atom . a) (atom . b))

Example: 12

(system
  ((init Main ()))
  (define (Aux) (Init (send (parent) foo)))
  (define (Main) (Init (spawn Aux ())) (foo (output bar))))

Output

((atom . bar))

Example: 13

(system
  ((init Main ()))
  (define (Aux) (na (output failure)))
  (define (Main)
    (Init (stay (spawn Aux ())))
    ((Died Match_error Msg)
      (let ([true (= (state) (from))]) (output Msg)))))

Output

((sys . Init))

Example: 14

(system
  ((init Main ()))
  (define (Counter)
    (poke (stay (+ (state) 1)))
    (tell (output (state)))
    (_ ()))
  (define (Main)
    (Init
      (let ([Id (spawn Counter 0)])
        (match (send Id poke)
          [1 (output whoops)]
          [2 (output whoops)]
          [(A B) (output whoops)]
          [() (send Id tell)])))))

Output

((number . 1))

Example: 15

(system
  ((init Main ()))
  (define (Main)
    (Init (send (self) 0))
    (X (match (= X 100000)
         [false (send (self) (+ X 1))]
         [true (output success)]))))

Output

((atom . success))

Example: arith

(system
  ((init Main ()))
  (define (Main) (_ (seq (output (+ 1 2)) (output (+ 0 7))))))

Output

((number . 3) (number . 7))

Example: eq

(system
  ((init Main ()))
  (define (Main)
    (_ (seq (output (= 1 1)) (output (= 1 2)) (output (= 1 foo))
            (output (= foo foo)) (output (= foo bar)) (output (= () ()))
            (output (= 1 ()))))))

Output

((atom . true) (atom . false) (atom . false) (atom . true)
  (atom . false) (atom . true) (atom . false))

silly-actor's People

Contributors

rootmos avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.