aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2024-05-26 22:32:05 +0100
committerJuan J. Martinez <jjm@usebox.net>2024-05-26 22:32:05 +0100
commit992d0ab8a72020420e2af2f199289fd739772879 (patch)
tree31de5938a75d25575271897211724b541c5e9ed9
parent6be7eba8977a719146ffa8c3e9485bc22ec31855 (diff)
downloadfunco-992d0ab8a72020420e2af2f199289fd739772879.tar.gz
funco-992d0ab8a72020420e2af2f199289fd739772879.zip
Also strings
-rw-r--r--README.md2
-rwxr-xr-xfunco2
2 files changed, 2 insertions, 2 deletions
diff --git a/README.md b/README.md
index a8e355d..fcbb5bd 100644
--- a/README.md
+++ b/README.md
@@ -93,7 +93,7 @@ Other built-in functions are:
* `head(list)`: returns the first element of a list
* `tail(list)`: returns the end of a list excluding the first element
* `empty?(list)`: returns true if a list is empty
-* `size(list)`: returns the size of a list
+* `size(list)`: returns the size of a list or a string
* `min(list)`: returns the smaller value in a list
* `max(list)`: returns the larger value in a list
* `contains(value list)`: returns true if a list contains a value
diff --git a/funco b/funco
index c6d0299..aab0a0c 100755
--- a/funco
+++ b/funco
@@ -407,7 +407,7 @@ def default_env():
"head": lambda xs: xs[0],
"tail": lambda xs: xs[1:],
"empty?": lambda xs: xs == [],
- "size": lambda xs: len(xs) if isinstance(xs, list) else None,
+ "size": lambda xs: len(xs) if isinstance(xs, (list, str)) else None,
"min": lambda xs: min(xs) if isinstance(xs, list) else None,
"max": lambda xs: max(xs) if isinstance(xs, list) else None,
"contains": lambda x, xs: x in xs,