Live functions deployed on OtherFunc highlighting different platform features.
Want yours listed here?
Send us a link.
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.
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
# 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.
Functions can reach out to the internet. http-get suspends
the interpreter, performs the fetch, then resumes execution
with the response.
(display "Your IP: ") (display (http-get "https://httpbin.org/ip")) (newline)
curl https://api.otherfunc.com/fn/example-fetch
Returns the server's IP address, fetched live from httpbin.org.
Brainfuck can make HTTP requests using memory-mapped I/O. The Lisp example above does it in 3 lines. In Brainfuck, the same task takes ~35,000 characters.
Navigate to URL buffer (cell 30,000) >>>>>...>>>>> 30,000 > characters Write "https://httpbin.org/ip" byte-by-byte ++++...++++++ > 104 +'s = 'h' (0x68), advance ++++...++++++ > 116 +'s = 't' (0x74), advance ... (22 bytes total, ~2,100 characters) Navigate to IO_METHOD (cell 32,001) >>>>>...>>>>> + 1,979 >'s, then set method = 1 (GET) Trigger I/O (cell 32,004) >>>+ Execution suspends, HTTP GET fires Navigate to response buffer (cell 31,000) <<<<<...<<<<< 1,004 < characters Print response [.>] Output bytes until null terminator
[.>] prints the response buffer until it hits a null bytecurl https://api.otherfunc.com/fn/example-bf-fetch
Returns the server's IP address — fetched live from httpbin.org by a 35,128-character Brainfuck program. See the reference docs for the complete memory-mapped I/O specification.
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.
n←⎕ ⋄ (⍳n)∘.×(⍳n)
curl -X POST -d "7" https://api.otherfunc.com/fn/example-apl-matrix
Returns a 7×7 multiplication table.
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.
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$
curl -X POST https://api.otherfunc.com/fn/example-reverse \ -d "Hello, World!"
Returns !dlroW ,olleH.
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.
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$)
INPUT (or POST body as webhook)HTTPHEADER + ENV$INSTR
BASIC can fetch data from the web using HTTPGET$.
10 REM Fetch data from the web
20 R$ = HTTPGET$("https://httpbin.org/get?greeting=hello")
30 PRINT "=== HTTP Response ==="
40 PRINT R$
curl https://api.otherfunc.com/fn/example-http-basic
Returns the httpbin.org echo response, showing the request URL and headers.
A guaranteed-fair random number generator, inspired by
xkcd #221.
Two loops compute (4×3+1)×4 = 52 (ASCII '4').
++++[->+++<]>+[->++++<]>.
curl https://api.otherfunc.com/fn/example-echo
Computes the first 20 Fibonacci numbers using recursive word definitions. Demonstrates Forth's stack-based calling convention and word compilation.
: fib dup 2 < if exit then dup 1 - recurse swap 2 - recurse + ; 20 0 do i fib . loop
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":""}'