Funktion

The Story Behind Funktion

The story behind this language begins in calculus II. I was introduced by Prof. Patrick Shanahan to the concept of parametrics, functions whose variables could be independently controlled by multiple discrete functions. I used what I had learned to expedite the design of bespoke graphical components for freelance animations.

This inspiration led me down a rabbit hole of mathematical discovery, which culminated in the development of my current senior project, Parametrix, a functional animation programming suite leveraging parametric notation for quickly automating short animations. I initially developed Funktion as a helpful way to make programming in this paradigm as quick and intuitive as possible. Although its syntax may be read by others as terse, it makes up for it with its brevity.

About Funktion

Funktion is a functional, generational, concise programming language that leverages aspects of parametric math notation, perfect for people who love math. Functions are defined as generators that are stepped through according to a global or local time step. The time step varies over an interval from a starting to ending point, allowing several independently-running functions to interact at different points in the program.

Language Features

Comments

// This is a comment! Oooga Booga
print("Hello, World!")

Types

Numbers

  • 42
  • 5.2

Characters

Each character is wrapped in single quotation marks.

  • 'a'
  • '\n' - Line Feed (New Line)
  • '\t' - Horizontal Tab
  • '\r' - Carriage Return
  • '\b' - Backspace
  • '\\' - Backslash Character (\)
  • '\"' - Double Quotation Character (")

Strings

Each string is wrapped in double quotation marks.

  • "Hello!"
  • "24t4t"
  • "Bob says \"Hello\" to you!"

Operators

Arithmetic Operators

OperatorDescriptionExample
+Addition4 + 5
-Negation-9
-Subtraction7 - 2
*Multiplication4 * 8
/Division12 / 3
**Exponentiation2 ** 9
%Modulus (Not Remainder)11 % 2

Bitwise Operators

OperatorDescriptionExample
~Bitwise Not~9
&Bitwise And7 & 3
|Bitwise Or2 | 8
<<Left Bit Shift7 << 2
>>Right Bit Shift64 >> 4

Relational Operators

OperatorDescriptionExample
==Equals9 == 9
!=Not Equals9 != 9
<Less Than9 < 9
<=Less Than or Equals9 <= 9
>Greater Than9 > 9
>=Greater Than or Equals9 >= 9

Miscellaneous Operators

OperatorDescriptionExample
+String Concatenation"Hi" + " Joe"

Ranges

Ranges are the building blocks of Funktion programming. They allow programmers to perform the same function multiple times.

Numerical Ranges

  • `0..10`0 1 2 3 4 5 6 7 8 9 10
  • `0..10 t1t`0 1 2 3 4 5 6 7 8 9 10
  • `10..0`10 9 8 7 6 5 4 3 2 1 0
  • `0..10 t-1t`0
  • `0..5 t0.2t`0 0.2 0.4 0.6 ... 4.6 4.8 5

Infinite Numerical Ranges (NOT IMPLEMENTED YET)

  • `0..`0 1 2 3 4 5 6 7 8 9 10 11 12 13...
  • `..0`0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13...

Character Ranges (NOT IMPLEMENTED YET)

  • `'a'..'e'`a b c d e
  • `'y'..'t'`y x w v u t
  • `'a'..'h' t2t`a c e g
  • `'Y'..'c'`Y Z [ \ ] ^ _ ` a b c

Functions

Declaring Functions

  • f(x) = 2x
  • g(x) = x

Calling Functions

  • f(x).step(3) - Calls the function 3 times.
  • print(f(x):2) - Prints the output of the function until 2.

Chain of Questioning

The chain of questioning allows you to perform a series of conditional checks using consecutive ? symbols. Each ? represents a case to be checked, and the : symbol represents the "else" condition.

Syntax:

? condition1 => action1
? condition2 => action2
? condition3 => action3
: defaultAction

Consecutive Action Operator

The consecutive action operator (,) allows you to chain multiple actions together on a single line. Actions are evaluated from left to right.

Syntax:

action1, action2, action3

Keywords

  • print - A print statement that prints the item into the console.
    • print("Bonjour!!!")

Code Examples

Hello World - (hello.funk)

Program below prints "Hello, World!".

// This example prints the simple program "Hello, World!"
print("Hello, World!")
Output:
Hello, World!

Factorial - (factorial.funk)

Program below prints the factorial of 5, which will output 120 after iterating through each product. This is created using a method that outputs the answer using a recursive algorithm.

`5..1` t1t

factorial(x) = ? x > 1 => x * factorial(x - 1) : 1 

factorial(x).step(5)  // Step through 5 times
print(x:1)
Output:
120
24
6
2
1

Combining Functions and Casting User Input

`1..5` t1t

f(x) = x
f(x).step(2)
G(x) = number(input("Give me a value and I will multiply that sequence with that value."))

(f(x) * G(x)).step(2)
print(f(x):5)
Expected Output:
1
2
3
20
25

Chain of Questioning, Consecutive Actions

`15..1` t1t

fizzbuzz(x) =
    ? x % 15 == 0 => print("fizzbuzz"), fizzbuzz(x).step()
    ? x % 3 == 0 => print("fizz"), fizzbuzz(x).step()
    ? x % 5 == 0 => print("buzz"), fizzbuzz(x).step()
    : print(x), fizzbuzz(x).step()
Expected Output:
fizzbuzz
14
13
fizz
11
buzz
fizz
8
7
fizz
buzz
4
fizz
2
1

Slice Example - (slices.funk)

`1..9` t3t

f(x) = x \ x + 1 \ x + 2
f(x).step(2)
print(f(x):7)
Expected Output:
1 2 3
4 5 6
7 8 9

The Funktion Team

Team Member 1

Wesley Ng

Wesley is a computer science major student who is interested in programming languages, video game development, and speedrunning. He currently is working on an 3-dimensional esolang that is intended to be interesting and difficult to program. He has worked on other projects for gaming including a 2D platformer and a slap card game, with some familiarity in Unity, Adobe Animate, and Aesprite. He is also working for professor Ray Toal on his research for Programming Languages Exploration where he explored 40+ languages and wrote many code snippets.

Team Member 2

Matthew Savitt

Matthew is a computer science major student who has a passion for technical animation, illustration, and roguelike video games. He currently is working on a suite of web-based animation software that allows for functional programming of animations. He has worked on other projects including Squibble, a web based public whiteboard, and works as a freelance cartoonist and animator. He hopes to one day design software that can make animation faster while remaining deeply personalizable.

Team Member 3

Reed Maniscalchi

Reed is a computer science and statistics & data science major who is interested in video game design and mathematics. He is currently working on a strategic 4-player board game, a research paper for approximating mathematical constants using Minecraft, and a graphics library for a customizable underwater aquarium. He has worked on other projects such as a mobile app that can search for new songs based on the user's music preferences.