本页尚未翻译,以下为英文原文。
#Rosetta: Common Tasks
Small, well-known programming tasks solved in Nabi, in the spirit of Rosetta Code: FizzBuzz, a sieve of primes, a Caesar cipher, eight queens. If you know how a task looks in another language, these pages show how it reads in this one. Every block is a complete script, compiled and run when the site is built, with its output under it.
| Page | Tasks |
|---|---|
| Text | reverse, palindromes, word counts, a Caesar cipher, columns, split and join, case, patterns |
| Numbers | FizzBuzz, Fibonacci, big factorials, a prime sieve, GCD, Roman numerals, parsing, rounding, random numbers |
| Collections | duplicates, sorting by key, grouping, sets, zip and flatten, largest by a measure, stacks and queues |
| Algorithms | binary search, quicksort, Towers of Hanoi, permutations, eight queens, a shortest path, matrix products |
| Files and data | wc, CSV, a configuration file, JSON, walking a directory, environment variables, running a program |
For numerical and data work, Science with Nabi points to a tutorial for each science package. Each task links back to the guide only where it uses something new; the guide's How Do I... chapter has short answers to everyday system tasks.
- Algorithms
Classic small algorithms, written plainly. The standard library already has most of them (
sort,binary_search,permutations); writing them out shows how Nabi reads. - Collections
Tasks with lists, dictionaries and sets.
List,DictandSetare shared handles: assigning one does not copy it,clone()does. - Files and Data
Reading and writing files and common data formats. Each script works in a fresh directory under the system's temporary directory and removes it at the end. For one-line answers (read a file, read stdin, arguments, dates) see How Do I....
- Numbers
Arithmetic tasks, from FizzBuzz to big integers. Integer types have fixed sizes (
i32,i64,u8..) and overflow is an error, not a silent wrap;inthas no size limit. - Text
Common tasks with strings. Each block is a complete script; the output under it is what it prints.
Found a mistake? Edit this page on GitHub. Last updated