Idiom #29 Remove item from list, by its index
Remove i-th item from list items.
This will alter the original list or return a new list, depending on which is more idiomatic.
Note that in most languages, the smallest valid value for i is 0.
Idiom #205 Get an environment variable
Read an environment variable with the name "FOO" and assign it to the string variable foo. If it does not exist or if the system does not support environment variables, assign a value of "none".
Idiom #2 Print Hello 10 times
Loop to execute some code a constant number of times
- Ada
- C
- Caml
- Clojure
- Cobol
- C++
- C#
- C#
- C#
- D
- D
- Dart
- Dart
- Elixir
- Erlang
- Fortran
- Go
- Go
- Go
- Groovy
- Haskell
- JS
- JS
- JS
- JS
- Java
- Java
- Java
- Kotlin
- Kotlin
- Kotlin
- Lisp
- Lua
- Lua
- Lua
- Lua
- Obj-C
- PHP
- PHP
- Pascal
- Perl
- Perl
- Perl
- Prolog
- Python
- Python
- Python
- Ruby
- Ruby
- Ruby
- Rust
- Rust
- Scala
- Scala
- Scheme
- Scheme
- Scheme
- Smalltalk
- VB
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.
Idiom #143 Iterate alternatively over two lists
Iterate alternatively over the elements of the lists items1 and items2. For each iteration, print the element.
Explain what happens if items1 and items2 have different size.
Idiom #46 Extract beginning of string (prefix)
Create the string t consisting of the 5 first characters of the string s.
Make sure that multibyte characters are properly handled.
Idiom #38 Extract a substring
Find substring t consisting in characters i (included) to j (excluded) of string s.
Character indices start at 0 unless specified otherwise.
Make sure that multibyte characters are properly handled.
Idiom #137 Check if string contains only digits
Set the boolean b to true if the string s contains only characters in the range '0'..'9', false otherwise.
Idiom #144 Check if file exists
Set boolean b to true if file at path fp exists on filesystem; false otherwise.
Beware that you should never do this and then in the next instruction assume the result is still valid, this is a race condition on any multitasking OS.
Idiom #176 Hex string to byte array
From hex string s of 2n digits, build the equivalent array a of n bytes.
Each pair of hexadecimal characters (16 possible values per digit) is decoded into one byte (256 possible values).
Idiom #22 Convert string to integer
Extract the integer value i from its string representation s (in radix 10)