From 0e4a95f54de4de668f3f010f312c011772b5f563f487f222ca3ed0d9538ab6fd Mon Sep 17 00:00:00 2001 From: Apache Date: Tue, 25 Jun 2024 00:39:43 -0500 Subject: [PATCH] Readme additions --- README.md | 27 +++++++++++++++++++++++++++ src/test.lisp | 5 +++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 360fb0f..39c2f1f 100644 --- a/README.md +++ b/README.md @@ -27,4 +27,31 @@ An opinionated lisp implementation developed in the most intuitive way I could c 1 ,(sub 3 1) ) ) ; => '( 1 2) +``` + +### Maps can be indexed with . + +```lisp +; In this example, ball_pos is a map +(print ball_pos.x ball_pos.y) + +; This is just syntax sugar for +(get ball_pos "x") +``` + +### Functions can be defined and called like so + +```lisp +(fn hello(name) ( + (print (concat "Hello, " name "!")) +)) + +(hello "Joe") ; => "Hello, Joe!" + + +; Anonymous function creation +( + (fn(x) (print x)) + 15 +) ; => 15 ``` \ No newline at end of file diff --git a/src/test.lisp b/src/test.lisp index d09e17e..b6856e2 100644 --- a/src/test.lisp +++ b/src/test.lisp @@ -1,4 +1,5 @@ (fn takevalue(origin) ( - (print (concat "Origin: (" origin.x ", " origin.y ")")) - (print origin) + (print (concat "Origin: (" origin.x ", " origin.y ")")) ; => Origin: (0, 0) + (print origin) ; => Map({"x": Float(0.0), "y": Float(0.0)}) )) +