diff options
author | Juan J. Martinez <jjm@usebox.net> | 2024-05-26 21:22:40 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2024-05-26 21:22:40 +0100 |
commit | 00680c131470b7f14243cdc3271fb302d8cfc4f7 (patch) | |
tree | 8fddf0c68eb7e29f8941917d694909f8b302199e | |
parent | 3283d727e74c3812efd19102cccbd4dd08684e92 (diff) | |
download | funco-00680c131470b7f14243cdc3271fb302d8cfc4f7.tar.gz funco-00680c131470b7f14243cdc3271fb302d8cfc4f7.zip |
A range function
-rw-r--r-- | README.md | 1 | ||||
-rwxr-xr-x | funco | 3 |
2 files changed, 4 insertions, 0 deletions
@@ -103,6 +103,7 @@ Other built-in functions are: * `take(n list)`: return the first n elements of a list * `drop(n list)`: return the list dropping the n first elements * `display(value)`: prints its arguments to the screen, for example `display("hello" "world")` +* `..(i j)`: generate a list of integers from i to j See the examples in `./examples`. @@ -411,6 +411,9 @@ def default_env(): "take": lambda n, xs: xs[:n], "drop": lambda n, xs: xs[n:], "display": print, + "..": lambda f, t: list(range(f, t + 1, 1) if f < t else range(f, t - 1, -1)) if ( + isinstance(f, int) and isinstance(t, int) + ) else None } ) return env |