From 1a3dc02a18a9050877288a5867e44d9c47a53542 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Sat, 11 Jan 2020 02:53:36 +0000 Subject: Added int width specifiers The width of an int can be specified at the site of its creation. For example, the following function returns an int of width 2 bits and value 1: [def two_bit_int [] (2 1)] Ints can still be written the old way; in these cases the compiler looks for a default int bit-width (specified with the -w flag). If a default has not been defined, the compiler throws an error. --- examples/nq/list.sin | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'examples/nq/list.sin') diff --git a/examples/nq/list.sin b/examples/nq/list.sin index 87c2509..2023a95 100644 --- a/examples/nq/list.sin +++ b/examples/nq/list.sin @@ -2,9 +2,13 @@ [type nil_ [kind]] [dec = [x y]] +[dec + [x y]] +[dec - [x y]] [dec !> [c a]] +[dec inc [x]] + [def cons [head tail] [list_ 0 head tail]] @@ -28,7 +32,7 @@ [def _length [xs n] [if [is_nil xs] n - [_length [tail xs] [+ n 1]]]] + [_length [tail xs] [inc n]]]] [def length [xs] [_length xs 0]] -- cgit v1.2.1