Skip to content

Instantly share code, notes, and snippets.

@lyxal
Created August 23, 2021 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lyxal/e3e37a905792051cbc88d5b7980f5554 to your computer and use it in GitHub Desktop.
Save lyxal/e3e37a905792051cbc88d5b7980f5554 to your computer and use it in GitHub Desktop.
element: +
name: add
arity: 2
description: adds the top two items on the stack
num-num: a + b
num-str: str(a) + b
str-num: a + str(b)
str-str: a + b
vectorise: yes
tests:
: [1, 1] -> 2
: [0, -5] -> -5
: ["abc", 5] -> "abc5"
: [5, "abc"] -> "5abc"
: ["Hello, ", "World!"] -> "Hello, World!"
: [[1,2,3], 4] -> [5, 6, 7]
: [[1,2,3], [4,5,6]] -> [5, 7, 9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment