From 992d0ab8a72020420e2af2f199289fd739772879 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 26 May 2024 22:32:05 +0100 Subject: Also strings --- README.md | 2 +- funco | 2 +- 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, -- cgit v1.2.3