Adds stem(), short_stem(), and long_ext(); also adds doc-comments to base() and ext().
The 'stem' is usually 'the name' of the file; the basename without the file extension.
To this end, this adds stem(), which is such that:
stem(path) + ext(path) = base(path)
However, 'file extension' has two different meanings to what constitutes it!
> What is the extension of: 'name.tar.gz' ?
Colloquially, you would likely think of it as 'a tarball' - which you might think is '.tar.gz'.
But, if you're writing code to process a file of this type, you would first treat it
as a Gzip file, and then treat the result as a TAR file - i.e: '.gz' ... _followed by_ '.tar'.
ext() returns '.gz' here, since that is the most-immediate format that you would need to use
to decode it; it would be a Gzip stream.
Sometimes though, you do actually want to consider these longer file extensions.
Perhaps you're extracting a tarball, and what to know what to call the intermediate tar file;
perhaps you want to check to see if this file is a tarball, or just a Gzip file;
or maybe you just want 'the name' of the file, and not this "strange 'name-and-part-of-the-extension' thing".
So, this also adds short_stem() and long_ext(), such that:
short_stem(path) + long_ext(path) = base(path)
Thus, we can use either, but the most immediately-useful one is the easiest to reach for:
stem('name.tar.gz') -> 'name.tar'
ext('name.tar.gz') -> '.gz'
short_stem('name.tar.gz') -> 'name'
long_ext('name.tar.gz') -> '.tar.gz'
These procedures are identical to their counterparts when the path only has a simple extension:
stem('name.txt') -> 'name'
ext('name.txt') -> '.txt'
short_stem('name.txt') -> 'name'
long_ext('name.txt') -> '.txt'
The Data-Oriented Language for Sane Software Development.
The Odin Programming Language
Odin is a general-purpose programming language with distinct typing, built for high performance, modern systems, and built-in data-oriented data types. The Odin Programming Language, the C alternative for the joy of programming.
Website: https://odin-lang.org/
package main
import "core:fmt"
main :: proc() {
program := "+ + * 😃 - /"
accumulator := 0
for token in program {
switch token {
case '+': accumulator += 1
case '-': accumulator -= 1
case '*': accumulator *= 2
case '/': accumulator /= 2
case '😃': accumulator *= accumulator
case: // Ignore everything else
}
}
fmt.printf("The program \"%s\" calculates the value %d\n",
program, accumulator)
}
Documentation
Getting Started
Instructions for downloading and installing the Odin compiler and libraries.
Nightly Builds
Get the latest nightly builds of Odin.
Learning Odin
Overview of Odin
An overview of the Odin programming language.
Frequently Asked Questions (FAQ)
Answers to common questions about Odin.
Packages
Documentation for all the official packages part of the core and vendor library collections.
The Odin Wiki
A wiki maintained by the Odin community.
Odin Discord
Get live support and talk with other odiners on the Odin Discord.
Articles
The Odin Blog
The official blog of the Odin programming language, featuring announcements, news, and in-depth articles by the Odin team and guests.
Warnings
- The Odin compiler is still in development.