Erlang Add
-module(add).
-export([add/2]).
add(Param1, Param2) ->
Param1 + Param2.
This just adds the two input numbers with the language’s normal arithmetic and returns the sum.
Go Add
func add(param1, param2 int) int {
return param1 + param2
}
This just adds the two input numbers with the language’s normal arithmetic and returns the sum.
Haskell Add
add :: Num a => a -> a -> a
add param1 param2 = param1 + param2
This just adds the two input numbers with the language’s normal arithmetic and returns the sum.
Java Add
public class Solution {
public static int add(int param1, int param2) {
return param1 + param2;
}
}
This just adds the two input numbers with the language’s normal arithmetic and returns the sum.
Lisp Add
(defun add (param1 param2)
(+ param1 param2))
This just adds the two input numbers with the language’s normal arithmetic and returns the sum.
PHP Add
function add($param1, $param2) {
return $param1 + $param2;
}
This just adds the two input numbers with the language’s normal arithmetic and returns the sum.
Python Add
def add(param1: int, param2: int) -> int:
return param1 + param2
This just adds the two input numbers with the language’s normal arithmetic and returns the sum.
Rust Add
fn add(param1: i64, param2: i64) -> i64 {
param1 + param2
}
This just adds the two input numbers with the language’s normal arithmetic and returns the sum.
TypeScript Add
function add(param1: number, param2: number): number {
return param1 + param2;
}
This just adds the two input numbers with the language’s normal arithmetic and returns the sum.
Bash Add Border
add_border() {
local -n _pic="$1"
local -n _outPic="$2"
local _width=${#_pic[0]}
local _border
_border=$(printf '%*s' "$_width" '' | tr ' ' '*')
_outPic=("$_border")
local _line
for _line in "${_pic[@]}"; do
_outPic+=("*${_line}*")
done
_outPic+=("$_border")
}
This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.