Change

From Esolang
Jump to navigation Jump to search

Change is a substitution based programming language and can be translated to lambda calculus

Some Things

Text

Use " to make text

"hello"
"some text"

Use ' (if you want) to make letter

'a'
'b'
'this is also valid'
"s"
"o is the previous one"

Substitutions

text(a)(b) replace all a's in text with b

"hello"('e')('o') #hollo
"text"("ex")("xe") #txet

Vars

vars are for simplification like how vars are used in some lambda calculuses

a = "hi"
b = "hello"
c = "hi world"("hi")("hello") #hello world
c #hello world

Funcs

also a simplification

sToEs a:
  return a('s')('es')
sToEs("potatos") #potatoes

Lambda Calculus

i said it could be translated to lambda calculus, so this is how

Example

id = λx.x
id x #x

that is a lambda abstraction for the identity function heres it in change

id a:
  return a
id "x" #x

How To Do

take all inputs of the function

λxy.yx

which is x, y put them in a function

func x y:
  ...

then insert the code for it

func x y:
  return y(x)

done

Another Way?

You can use all of the substitution stuff to do it:

Before

id = λx.x
id y #y

After

same = "x"
id x:
  return same("x")(x)
id "y" #y