FIND YOUR NEXT FEW LINES

Results for “fold”

Small, practical examples. Search by task or narrow things down below.

668 snippets foundClear filters
RustFunctions & data types

Use an associated constructor

Use an associated constructor in a complete Rust program using the standard library.

Rust✓ Tested
RustGetting Started

Use if to produce a value

Use if to produce a value in a complete Rust program using the standard library.

Rust✓ Tested
Bash ScriptsArguments & decisions

Validate the number of positional arguments

Bash Scripts: Use the argument count to enforce a simple command-line contract.

Bash Scripts✓ Tested
GoErrors & validation

Validate UTF-8 bytes

Validate UTF-8 bytes using a complete Go program with explicit sample inputs.

Go✓ Tested
Linux CommandsArchive integrity & packaging

Verify a file against a checksum manifest

Linux Commands: Use sha256sum -c with a manifest obtained from a trusted source.

Linux Commands✓ Tested
Bash ScriptsArray operations

Visit associative-array keys in a stable order

Bash Scripts: Associative arrays have no defined iteration order, so sort their keys explicitly.

Bash Scripts✓ Tested
Bash ScriptsProcesses & environment

Wait for a background job before reading its output

Bash Scripts: Save the job PID and wait explicitly before consuming files it produces.

Bash Scripts✓ Tested
Docker / ComposeCompose applications

Wait for an initialization job

Start a service only after its dependency completes successfully.

Compose✓ Tested
GoConcurrency & cancellation

Wait for concurrent workers

Wait for concurrent workers using a complete Go program with explicit sample inputs.

Go✓ Tested
RustFunctions & data types

Wrap a value in a distinct type

Wrap a value in a distinct type in a complete Rust program using the standard library.

Rust✓ Tested
GoErrors & validation

Wrap an error with context

Wrap an error with context using a complete Go program with explicit sample inputs.

Go✓ Tested
GoFunctions & types

Write a generic slice helper

Write a generic slice helper using a complete Go program with explicit sample inputs.

Go✓ Tested