This is a small collection of code snippets for the Odin programming language.
This is made by a very inexperience (when it comes to C) programmer, so there will be bugs!
In each of the folders in tests
is a folder with the code and resources needed to test each helper. Go there for examples on how to use the procedures.
md5.odin
- Implementation of the MD5 hashing algorithm in pure Odin.hash([]u8): string
Takes a single messages and return it's hash.
str.odin
- String helper procedures.indexOf(string, string): int
Takes astring
to search in, and astring
to search for. Can also search forrune
s andu8
s.lastIndexOf(string, string): int
Takes astring
to search in, and astring
to search for. Searches from end to beginning of the string. Can also search forrune
s andu8
s.startsWith(string, string): bool
Takes astring
to search in, and astring
to search for. Can also search forrune
s andu8
s.join([]string, string): string
Takes a[]string
to join with the separator. Separator can also be arune
or au8
.split(string, rune): []string
Takes a ´string´ and split it into a list ofstring
s using a single separator.trimStart(string): string
Takes astring
and trim the leading whitespace.trimEnd(string): string
Takes astring
and trim the trailing whitespace.trim(string): string
Takes astring
and trim leading and trailing whitespace.
file.odin
- File helper proceduresread_lines(string): []string
A procedure that takes a string which is a path to a file. The file will be read in it's full length and returned as a[]string
where each entry in the list represents a line in the file. The file will be split on\n
,\r
and\r\n
which is Unix, Mac and Windows line endings.
- Possibly other, newer hashing functions (that are not already in hash.odin).
Reading files, line by line - not caring about Unix or Windows line endings.