XCODX |

F# Interactive Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About F# Interactive

F# Interactive — fsi, the engine behind dotnet fsi — is how most F# developers actually explore code: no project files, no build step, just evaluate and see. It executes .fsx-style scripts and is the backbone of F#'s celebrated REPL-driven workflow, used for everything from data exploration to build scripting (the FAKE build system runs on it). Under the hood it's the same F# compiler and .NET runtime as compiled F#, so results are identical — you simply skip the ceremony. Scripting is a first-class scenario in current F# releases on modern .NET. On this page, fsi runs your script against a genuine interactive terminal: ReadLine pauses for your typed input and every printfn streams instantly.

Hello World in F# Interactive

let rec collatz steps n =
    match n with
    | 1L -> steps
    | n when n % 2L = 0L -> collatz (steps + 1) (n / 2L)
    | n -> collatz (steps + 1) (3L * n + 1L)

printf "Pick a starting number: "
let start = int64 (System.Console.ReadLine())
printfn "From %d, the Collatz sequence reaches 1 in %d steps." start (collatz 0 start)

printf "Pick another to compare: "
let second = int64 (System.Console.ReadLine())
let winner = if collatz 0 second > collatz 0 start then second else start
printfn "%d takes more steps. Try beating it!" winner

When to use F# Interactive

Reach for fsi when iteration speed matters more than a build artifact: sketching an algorithm, checking what the type checker infers, verifying a pattern match, or doing quick calculations with .NET libraries. It mirrors the workflow F# developers use daily in VS Code's FSI panel, so students learning F# in a functional programming course can practice the exact evaluate-inspect-refine loop their tooling expects. It's also handy for comparing script behavior against the compiled F# variant when debugging something subtle like startup or console encoding differences.

Common questions

Can my script prompt me for input mid-run?

Yes — even though fsi is a script evaluator, your code runs attached to this page's live terminal, so System.Console.ReadLine() blocks until you type a response. Prompts written with printf appear first, making multi-question interactive scripts work the same as they would in a local dotnet fsi session.

When should I pick fsi over the compiled F# .NET variant?

Pick fsi for exploration: it starts evaluating without a separate build, which suits quick experiments, homework snippets, and iterating on a function. Pick the compiled variant when you want behavior identical to a shipped binary. The language is the same; only the execution pipeline differs, and results match for typical code.

Do #r nuget directives work for loading packages?

No — the sandbox has no network package restore, so #r "nuget: ..." won't fetch anything, and execution is limited to one script file. The full .NET base class library and FSharp.Core are available directly, which covers collections, LINQ-style Seq pipelines, regex, math, and JSON via System.Text.Json.

How F# Interactive runs on XCODX

Sandbox filename
main.fsx
Entry point
main.fsx script entrypoint
Editor grammar
mllike
Reading stdin
Console.ReadLine()
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

// F# Interactive
printfn "Hello from F# Interactive!"
printfn "Welcome to XCODX Online Compiler!"

let factorial n =
    let mutable result = 1
    for i in 1..n do
        result <- result * i
    result

printfn "5! = %d" (factorial 5)
printfn "10! = %d" (factorial 10)