Showcase

Live functions deployed on OtherFunc highlighting different platform features.
Want yours listed here? Send us a link.

Forth — Prime Sieve Dashboard

Response Control Memory Computation

A Sieve of Eratosthenes that uses Forth memory cells (addresses 1000+) as a flag array. Defines words for init, mark, and check, runs the sieve, then renders the results as an HTML page using response control.

Code

s" HTTP/1.0 200" type cr
s" Content-Type: text/html" type cr cr

: init   101 2 do 1 i 1000 + ! loop ;
: prime? ( n -- f ) 1000 + @ ;
: mark   ( n -- )  0 swap 1000 + ! ;

: sieve  ( -- )
  init
  11 2 do
    i prime? if
      101 i dup * do  i mark  j +loop
    then
  loop ;

: show  ( -- )
  101 2 do  i prime? if i . then  loop ;

: count  ( -- n )
  0  101 2 do  i prime? if 1 + then  loop ;

sieve

s" <body style='font-family:Georgia,serif;max-width:500px;margin:40px auto;padding:20px'>" type
s" <h1>Prime Sieve in Forth</h1>" type
s" <p>Primes up to 100, found with the Sieve of Eratosthenes.</p>" type
s" <p>Memory addresses 1000-1100 are used as a flag array.</p>" type
s" <h2>Result</h2>" type
s" <p style='font-family:monospace;font-size:18px'>" type
show
s" </p>" type
s" <p><b>" type count . s" </b> primes found.</p>" type
s" <p><a href='https://otherfunc.com'>otherfunc.com</a></p>" type
s" </body>" type

Try it

# Open in a browser:
https://api.otherfunc.com/fn/example-webpage

# Or via curl:
curl https://api.otherfunc.com/fn/example-webpage

You'll see a rendered HTML page listing all 25 primes up to 100.

Lisp — Fetch External Data

HTTP Outbound

Functions can reach out to the internet. http-get suspends the interpreter, performs the fetch, then resumes execution with the response.

Code

(display "Your IP: ")
(display (http-get "https://httpbin.org/ip"))
(newline)

Try it

curl https://api.otherfunc.com/fn/example-fetch

Returns the server's IP address, fetched live from httpbin.org.

APL — Multiplication Table

Outer ProductMatrix Output

POST a number N and get an N×N multiplication table. generates 1…N, and ∘.× (outer product) computes every pairwise product, producing a formatted matrix.

Code

n←⎕ ⋄ (⍳n)∘.×(⍳n)

Try it

curl -X POST -d "7" https://api.otherfunc.com/fn/example-apl-matrix

Returns a 7×7 multiplication table.

BASIC — String Reverser Webhook

Webhook Input

POST any text to this endpoint and get it back reversed. The POST body becomes the program's input via INPUT. Classic BASIC string functions do the rest.

Code

10 INPUT S$
20 LET R$ = ""
30 FOR I = LEN(S$) TO 1 STEP -1
40 LET R$ = R$ + MID$(S$, I, 1)
50 NEXT I
60 PRINT R$

Try it

curl -X POST https://api.otherfunc.com/fn/example-reverse \
  -d "Hello, World!"

Returns !dlroW ,olleH.

BASIC — AI Chat Agent

HTTP Outbound KV Storage Secrets

A chatbot that calls an LLM via OpenRouter, returns the response, and remembers conversation history in KV storage. HTTPHEADER sets the auth token from a secret, HTTPPOST$ calls the API, and INSTR parses the JSON response.

Code

10 INPUT Q$
20 IF Q$ = "" THEN END
30 H$ = KVGET$("history")
40 IF H$ = "" THEN H$ = "[]"
50 REM Append user message
60 IF LEN(H$) = 2 THEN H$ = "[" : GOTO 80
70 H$ = LEFT$(H$, LEN(H$) - 1) + ","
80 M$ = "{""role"":""user"",""content"":""" + Q$ + """}"
90 H$ = H$ + M$ + "]"
100 REM Build request body
110 B$ = "{""model"":""openai/gpt-4o-mini"",""messages"":" + H$ + "}"
120 REM Call LLM
130 HTTPHEADER "Authorization", "Bearer " + ENV$("OPENROUTER_KEY")
140 R$ = HTTPPOST$("https://openrouter.ai/api/v1/chat/completions", B$)
150 REM Parse response
160 P = INSTR(R$, """content"":""")
170 IF P = 0 THEN PRINT "Error: " + R$ : END
180 P = P + 11
190 T$ = MID$(R$, P, LEN(R$))
200 E = INSTR(T$, """")
210 A$ = MID$(T$, 1, E - 1)
220 PRINT A$
230 REM Save history with assistant reply
240 H$ = LEFT$(H$, LEN(H$) - 1)
250 H$ = H$ + ",{""role"":""assistant"",""content"":""" + A$ + """}]"
260 X$ = KVSET("history", H$)

How it works

  1. Reads user question via INPUT (or POST body as webhook)
  2. Loads chat history from KV (persists across calls)
  3. Builds an OpenRouter-compatible JSON request with the full conversation
  4. Sets the API key from a secret via HTTPHEADER + ENV$
  5. POSTs to OpenRouter, parses the response with INSTR
  6. Saves updated history (user + assistant messages) back to KV

BASIC — HTTP Fetch

HTTP Outbound

BASIC can fetch data from the web using HTTPGET$.

Code

10 REM Fetch data from the web
20 R$ = HTTPGET$("https://httpbin.org/get?greeting=hello")
30 PRINT "=== HTTP Response ==="
40 PRINT R$

Try it

curl https://api.otherfunc.com/fn/example-http-basic

Returns the httpbin.org echo response, showing the request URL and headers.

Brainfuck — Random Number Generator

Esoteric Minimalism

A guaranteed-fair random number generator, inspired by xkcd #221. Two loops compute (4×3+1)×4 = 52 (ASCII '4').

Code

++++[->+++<]>+[->++++<]>.

Try it

curl https://api.otherfunc.com/fn/example-echo

Forth — Fibonacci Sequence

Forth Stack Gymnastics

Computes the first 20 Fibonacci numbers using recursive word definitions. Demonstrates Forth's stack-based calling convention and word compilation.

Code

: fib dup 2 < if exit then
  dup 1 - recurse swap 2 - recurse + ;
20 0 do i fib . loop

Try it

curl -X POST https://api.otherfunc.com/api/run \
  -H "Content-Type: application/json" \
  -d '{"language":"forth","code":": fib dup 2 < if exit then dup 1 - recurse swap 2 - recurse + ; 20 0 do i fib . loop","input":""}'
Build your own.
Get an API Key