Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new forms to lisp #385

Merged
merged 22 commits into from
Aug 25, 2022
Merged

Add new forms to lisp #385

merged 22 commits into from
Aug 25, 2022

Conversation

vinc
Copy link
Owner

@vinc vinc commented Aug 10, 2022

  • Add list form
  • Add string form
  • Rename bytes to encode-string
  • Add decode-string form
  • Add encode-number and decode-number forms
  • Rename read and read-bytes to read-file and read-file-bytes
  • Add write-file-bytes and append-file-bytes forms
  • Add write-file and append-file simplified forms
  • Add read-char form
  • Add uptime form
  • Add regex-find and regex-match? forms
  • Add not form

@vinc
Copy link
Owner Author

vinc commented Aug 10, 2022

Got a suggestion to use write-bytes to implement print which is very interesting, we could indeed do (defn print (s) (write-bytes "/dev/console" (bytes s))) but write-bytes try to create a new file so it doesn't work. We'll need to append instead.

@vinc vinc changed the title Add forms to lisp Add new forms to lisp Aug 13, 2022
@vinc
Copy link
Owner Author

vinc commented Aug 13, 2022

This last commit was made possible by #387

@vinc
Copy link
Owner Author

vinc commented Aug 14, 2022

> (list 1 2 3)
(1 2 3)

> (string (+ 1 2))
"3"

> (string "the answer is " 42)
"the answer is 42"

> (read-file-bytes "/dev/clk/uptime" 8)
(64 98 79 253 120 231 197 168)

> (decode-number (list 64 98 79 253 120 231 197 168))
146.49969144123065

> (uptime)
146.49969144123065

> (encode-string "foo")
(102 111 111)

> (decode-string (list 102 111 111))
"foo"

> (write-file-bytes "/tmp/hello.txt" (encode-string "Hello, "))
7

> (append-file-bytes "/tmp/hello.txt" (encode-string "World!"))
6

> (read-file "/tmp/hello.txt")
"Hello, World!"

@vinc
Copy link
Owner Author

vinc commented Aug 15, 2022

> (write-file "/tmp/hello.txt" "Hello, ")
7

> (append-file "/tmp/hello.txt" "World!")
6

> (read-file "/tmp/hello.txt")
"Hello, World!"

@vinc
Copy link
Owner Author

vinc commented Aug 19, 2022

> (not true)
false

> (not false)
true

> (not null)
false

> (not 1)
false

> (not 0)
false

@vinc
Copy link
Owner Author

vinc commented Aug 19, 2022

> (regex-match? "foo" "foo bar")
true

> (regex-match? "foo" "bar")
false

@vinc vinc marked this pull request as ready for review August 25, 2022 06:43
@vinc vinc merged commit b11f0ae into trunk Aug 25, 2022
@vinc vinc deleted the feature/lisp-bytes branch August 25, 2022 06:48
@vinc vinc mentioned this pull request Aug 30, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant