Darklang
1 program
Added 2026-02-26T10:00:00Z
Agent: claude-codeModel: claude-sonnet-4-6WebSearch: disabled
Evidence
Report issue
View issues
Aliases: Dark
Provenance: commit 8c4cc37c48 · authored 2026-02-26T18:27:45+01:00 · agent claude-code · model claude-sonnet-4-6
Sources mentioning this language
2 sources · pl_id:
pl/darklangRelated languages
Real programs from Software Heritage
No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)
Programs collected by LLM agents experimental · unverified
Gathered by LLM agents during the experiment that started this catalogue. They are not verified: the agent names an origin, but a program can be altered or invented — an audit found one attributed to a file that does not exist, in a syntax the language does not have. Prefer the programs archived by Software Heritage above. The catalogue's goal is the languages themselves, grounded in sources (PLDB, Wikipedia, Rosetta Code, …), with real archived programs; these examples may be dropped.
Stdlib List Operations
Provenance: commit 8c4cc37c48 · authored 2026-02-26T18:27:45+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch disabled
module Darklang.Stdlib.List
/// Returns an empty list
let empty = []
/// Returns a one-element list containing the given <param val>
let singleton (value: 'a) : List<'a> =
[ value ]
/// Returns {{Some}} the head (first value) of a list.
/// Returns {{None}} if the list is empty.
let head (list: List<'a>) : Option.Option<'a> =
match list with
| [] -> Option.Option.None
| head :: _ -> Option.Option.Some head
/// If <param list> contains at least one value, returns {{Some}} with a list of
/// every value other than the first. Otherwise, returns {{None}}.
let tail (list: List<'a>) : Option.Option<List<'a>> =
match list with
| [] -> Option.Option.None
| _ :: tail -> Option.Option.Some tail
/// Returns a new list with all values in <param as> followed by all values in <param bs>,
/// preserving the order
let append (as_: List<'a>) (bs: List<'a>) : List<'a> =
Builtin.listAppend as_ bs
/// Add element <param value> to front of <type list> <param list>
let push (list: List<'a>) (value: 'a) : List<'a> =
append [ value ] list
/// Add element <param val> to back of <type list> <param list>
let pushBack (list: List<'a>) (value: 'a) : List<'a> =
append list [ value ]
/// Returns the last value in <param list>, wrapped in an option (<paramNone> if the list is empty)
let last (list: List<'a>) : Option.Option<'a> =
match list with
| [] -> Option.Option.None
| head :: tail ->
match tail with
| [] -> Option.Option.Some head
| _ -> last tail
// Todo: remove the helper function once we have recursive lambdas
let reverseHelper (list: List<'a>) (acc: List<'a>) : List<'a> =
match list with
| [] -> acc
| head :: tail -> reverseHelper tail (push acc head)
/// Returns a reversed copy of <param list>
let reverse (list: List<'a>) : List<'a> = reverseHelper list []
/// Returns {{Some firstMatch}} where <var firstMatch> is the first value of the
/// list for which <param fn> returns {{true}}. Returns {{None}} if no such
/// value exists
let findFirst (list: List<'a>) (fn: 'a -> Bool) : Option.Option<'a> =
match list with
| [] -> Option.Option.None
| head :: tail ->
if (fn head) then
Option.Option.Some head
else
findFirst tail fn
/// Returns {{true}} if <param value> is in the list
let ``member`` (list: List<'a>) (value: 'a) : Bool =
Option.isSome (findFirst list (fun elem -> elem == value))