Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
This list is filtered with keywords : fortran

Idiom #305 Calculate exponentiation of real numbers

Compute and print a^b, and a^n, where a and b are floating point numbers and n is an integer.

Idiom #43 Break outer loop

Look for a negative value v in 2D integer matrix m. Print it and stop searching.

Control flow jumping forward after the end of the outermost loop

Idiom #71 Echo program implementation

Basic implementation of the Echo program: Print all arguments except the program name, separated by space, followed by newline.
Skip the first argument if necessary, concatenate arguments as strings, append newline and print it to stdout.

Idiom #284 Create a zeroed list of integers

Create a new list a (or array, or slice) of size n, where all elements are integers initialized with the value 0.

Idiom #134 Create a new list

Declare and initialize a new list items, containing 3 elements a, b, c.

Idiom #84 Count bits set in integer binary representation

Count number c of 1s in the integer i in base 2.

E.g. i=6 → c=2

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having the value x.
This will alter the original list or return a new list, depending on which is more idiomatic.
If there are several occurrences of x in items, remove only one of them. If x is absent, keep items unchanged.

Idiom #132 Measure duration of procedure execution

Run the procedure f, and return the duration of the execution of f.

Idiom #136 Remove all occurrences of a value from a list

Remove all occurrences of the value x from list items.
This will alter the original list or return a new list, depending on which is more idiomatic.

Idiom #47 Extract string suffix

Create string t consisting in the 5 last characters of string s.
Make sure that multibyte characters are properly handled.

The end of the string s

Idiom #252 Conditional assignment

Assign to the variable x the string value "a" if calling the function condition returns true, or the value "b" otherwise.

Idiom #25 Send a value to another thread

Share the string value "Alan" with an existing running process which will then display "Hello, Alan"

Idiom #3 Create a procedure

Like a function which doesn't return any value, thus has only side effects (e.g. Print to standard output)