GithubHelp home page GithubHelp logo

lagenorhynque / spec-examples Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 2.0 24 KB

clojure.spec examples

Home Page: https://www.slideshare.net/KentOhashi/spectacular-future-with-clojurespec

License: Eclipse Public License 1.0

Clojure 86.90% Java 13.10%
clojure clojure-spec blackjack

spec-examples's Introduction

spec-examples

CircleCI

clojure.spec examples.

Prerequisites

  • build tool Leiningen

    • Mac OS X: brew install leiningen
  • alternative: clj command

    • Mac OS X: brew install clojure

Experiment with REPL

  • with Leiningen
$ lein repl
  • with clj command
$ clj -R:dev -C:dev

This will start Clojure REPL with the following code already executed:

(require '[clojure.spec.alpha :as s]
         '[clojure.spec.gen.alpha :as gen]
         '[clojure.spec.test.alpha :as stest])

Run example code

  • with Leiningen
$ lein run -m spec-examples.core
  • with clj command
$ clj -m spec-examples.core

In Clojure REPL,

user=> (require '[spec-examples.blackjack.play :as bj])
nil
user=> (bj/init)
dealer: [[9 :spade] ???]
player: [[4 :diamond] [:ace :diamond]] => 15
nil
user=> (bj/hit)
dealer: [[9 :spade] ???]
player: [[3 :club] [4 :diamond] [:ace :diamond]] => 18
nil
user=> (bj/stand)
dealer: [[9 :spade] [8 :diamond]] => 17
player: [[3 :club] [4 :diamond] [:ace :diamond]] => 18
You win!! x1
nil

available commands

  • spec-examples.blackjack/init: initialise the game
  • spec-examples.blackjack/hit-by-player: hit operation by player
  • spec-examples.blackjack/stand-by-player: stand operation by player

spec-examples's People

Contributors

lagenorhynque avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

iku000888 pez

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.