Skip to content
admlangPublic

About

ADM lang examples

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ADM examples

Example programs for the ADM programming language, grouped by category.

Running an example

Install ADM from adm-lang.dev, clone this repository, and run an example from the repository root:

Examples

AI

Example Description
chat Chats with a GGUF language model in the terminal, with optional reasoning output and tool calls.
classifier CClassifies a support ticket with a decision model (Bespoke Nimble, or any chat model): typed questions answered with probabilities and other no text generated.
diffusion Draws a picture from a sentence with Stable Diffusion through std.ai.diffusion, with LoRAs (--lora FILE[:STRENGTH]), on the GPU when there is one.
experts Runs a mixture-of-experts model on a GPU too small to hold it: the same answer with less GPU memory, and the speed each budget gives.
embeddings Finds the sentences closest in meaning to a question with an embedding model (GGUF or ONNX) through std.ai.embeddings.
tune Teaches a chat model new facts with LoRA fine-tuning through std.ai.llm (model.tune, learn, save): a few epochs over example conversations, the GGUF adapter saved and loaded again, the answer before and after.
speak Text to speech with a Kokoro voice through std.ai.speech: reads text aloud through the speakers or into a sound file, American or British English.
whisper Speech to text with Whisper through std.ai.speech: whisper.adm writes down a sound file, listen.adm what you say into the microphone as you say it (Ctrl+C stops).

Database

Example Description
service Keeps orders and an audit trail in two databases held by the Database service, written to from three tasks through sql def functions.
sqlite Keeps a library of books in SQLite: bound arguments, rows read into structs, a transaction, and the statements again as sql def methods.

Devices

Example Description
camera Takes one picture with the first camera and saves it as a JPEG.
list Prints the devices of this computer: kind, name, USB identifiers, bus and node.
microphone Records three seconds from a microphone and plays them back.
securitykey Registers a FIDO2 security key for a made-up site and signs in with it, as a browser and a server would.
speakers Plays a one-second tone on every speaker.

Encoding

Example Description
barcodes Makes a barcode of every kind (QR, Data Matrix, Aztec, PDF417, EAN, UPC, Code 128 and more), saves each as an image and reads it back.
formats Writes one record as JSON, YAML, TOML, MessagePack and CBOR, reads it back, and writes bytes as hex, Base64 and Base32.

Graphics

Example Description
analysis Runs every image analysis on one picture: subject, colours, brightness, BlurHash, perceptual hashes and keypoints.
canvas-showcase 2D canvas API showcase: paths, borders, gradients, compositing, effects, layers, text, pictures, sprites and mesh warps.
filters Applies every image filter (grayscale, blur, sepia, hue, threshold and more) to one picture, with and without a mask.
gif-frames Splits an animated GIF into one PNG per frame and prints each frame's delay.
gpu_canvas An animated scene drawn on the GPU in a window, with a shader written in ADM.
icon-sizes Lists the images inside an icon or cursor file and writes the icon at a chosen size.
image-convert Reads an image in one format and saves it in another, picked by the output file's extension.
model-convert Converts a 3D model between glTF, GLB, OBJ and STL and prints its nodes, meshes, materials, skins and animations.
model-render Draws a 3D model (glTF, GLB, OBJ, STL) to a picture, or its animation to a GIF, with sample models of each kind beside it.
psd-layers Lists the layers of a Photoshop document and saves each visible layer as its own image.
seam-carving Resizes an image with seam carving, which removes the least important paths of pixels so the subject keeps its shape.
svg-animation Plays an animated SVG in a window, or writes its frames as PNG files.
thumbnail Scales an image down to fit a square, keeping its proportions.
transforms Applies every image transform to one picture: mirroring, cropping, padding, resizing with each algorithm and fitting into a box.
tiff-pages Lists the pages of a TIFF file and saves one of them.
webp-info Prints what a WebP file holds (encoding, transparency, animation frames, metadata) and converts it.

User interface

Example Description
components-showcase A window showing the std.ui components in the desktop theme's colours: text, buttons and their states, pressable content, rows, columns, panels and the theme's palette.
custom-chrome Two windows whose frames the program draws itself (WindowConfig.chrome): a rounded one with coloured dots for buttons, and a disc with none that is found by name and closed from the first.

Interop

Example Description
c Calls functions from a C file and from the C math library, and lets C call an ADM function back.
dotnet Calls the static methods of a C# class (arrays and strings both ways, null as none, an exception as an error), makes a .NET list and has .NET sort it with an ADM function.
go Calls a Go package the build compiles itself (@go): text statistics, and a sum its goroutines compute over an ADM array.
java Calls the static methods of a Java class (arrays and strings both ways, null as none, an exception as an error), makes a Java list and has Java sort it with an ADM function.
js Runs a shop's pricing rules written in JavaScript, calling the script's functions like ordinary ADM functions.
lua Works out customer discounts and badges with rules written in Lua, called like ordinary ADM functions.
rust Calls a Rust crate the build compiles itself (@rust), lets Rust write into a buffer and call an ADM function back.
zig Calls a Zig file the build compiles itself (@zig): a hash, primes written into an ADM array, and a callback for each step of a sequence.

Media

Example Description
media-player Plays audio and video files and internet radio in a window, with keys to pause, skip and change item.
midi Plays a MIDI file, or a scale built in code, through the built-in synthesizer.

Network

Example Description
http-client Fetches a web address and prints the status, a few headers and the start of the body.
http-server A small web server with four routes: a page, a greeting with a name from the path, a JSON reply and an echo.
irc-client Joins an IRC channel and prints the messages, joins and leaves as they happen.

License

MIT

About

ADM lang examples

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages