From 649e02f20903f50c04154d47a454c9ba297eb798 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 22 Dec 2017 11:29:33 +0000 Subject: [PATCH] Add basic example to README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index f02043a65..e21eb0059 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,30 @@ The Odin programming language is fast, concise, readable, pragmatic and open sou Website: [https://odin.handmade.network/](https://odin.handmade.network/) +```go +import "core:fmt.odin" + +main :: proc() { + program := "+ + * 😃 - /"; + accumulator := 0; + + for token in program { + switch token { + case '+': accumulator += 1; + case '-': accumulator -= 1; + case '*': accumulator *= 2; + case '/': accumulator /= 2; + case '😃': accumulator *= accumulator; + case: // Ignore everything else + } + } + + fmt.printf("The program \"%s\" calculates the value %d\n", + program, accumulator); +} + +``` + ## Demonstrations: * First Talk & Demo - [Talk](https://youtu.be/TMCkT-uASaE?t=338)