Giter VIP home page Giter VIP logo

typed-big-bang's Introduction

typed-big-bang

see also lexi-lambda/racket-2htdp-typed

(require typed/big-bang)

This does not provide a drop in replacement for big-bang from 2htdp/universe.

Instead of a macro, it provides a function, which has keyword arguments for #:on-tick, #:to-draw, etc.

You also have to provide a world? predicate, and use (inst big-bang World).

An example world program:

#lang typed/racket

(require typed/big-bang
         typed/2htdp/image)

(define-type World Integer)

(: main : [World -> World])
(define (main t)
  ((inst big-bang World)
   t
   exact-integer?
   #:on-tick add1
   #:to-draw render
   #:stop-when (λ ([t : Integer]) (<= 10000 t))
   #:on-key (λ ([t : Integer] [key : KeyEvent])
              (cond [(key=? key "+") (+ 1000 t)]
                    [else t]))
   #:on-release (λ ([t : Integer] [key : KeyEvent])
                  (- t 100))
   #:on-mouse (λ ([t : Integer] [x : Integer] [y : Integer] [me : MouseEvent])
                (- t 2))
   ))

(: render : [World -> Image])
(define (render t)
  (overlay (text (number->string t) 36 "black")
           (empty-scene 200 200)))

(main 0)

typed-big-bang's People

Contributors

alexknauth avatar

Watchers

Sam Tobin-Hochstadt avatar James Cloos 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.