FIND YOUR NEXT FEW LINES

Results for “Go”

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

182 snippets foundClear filters
GoGetting Started

Append to a slice

Append to a slice using a complete Go program with explicit sample inputs.

Go✓ Tested
GoFunctions & types

Attach behavior to a struct

Attach behavior to a struct using a complete Go program with explicit sample inputs.

Go✓ Tested
GoStrings & text

Build text incrementally

Build text incrementally using a complete Go program with explicit sample inputs.

Go✓ Tested
CSmall algorithms & bit operations

Calculate a fixed-window moving average

C: For this small window, sum each complete group and skip incomplete prefixes.

C✓ Tested
CSmall algorithms & bit operations

Calculate a least common multiple using a GCD

C: Divide before multiplying to reduce the risk of intermediate overflow.

C✓ Tested
GoJSON & encoding

Calculate a SHA-256 text digest

Calculate a SHA-256 text digest using a complete Go program with explicit sample inputs.

Go✓ Tested
CSmall algorithms & bit operations

Calculate a small factorial iteratively

C: Multiply a bounded sequence using an unsigned accumulator.

C✓ Tested
GoGetting Started

Calculate a subtotal

Calculate a subtotal using a complete Go program with explicit sample inputs.

Go✓ Tested
CSmall algorithms & bit operations

Calculate an average without integer division truncation

C: Accumulate into double and divide by the nonzero number of readings.

C✓ Tested
C++Sequence algorithms

Calculate changes between successive readings

C++: adjacent_difference keeps the first value and then writes each difference from its predecessor.

C++✓ Tested
C++Sequence algorithms

Calculate cumulative totals

C++: partial_sum writes the sum of each input prefix to the output sequence.

C++✓ Tested
C++Sequence algorithms

Calculate the dot product of two vectors

C++: inner_product multiplies corresponding elements and accumulates them from a chosen seed.

C++✓ Tested