docs

您正在閱讀 v0.1.2 的文件。Nabi 0.1.2 已停止支援。 最新版本:v0.1.3 →

本頁尚未翻譯,以下為英文原文。

#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.

PageTasks
Textreverse, palindromes, word counts, a Caesar cipher, columns, split and join, case, patterns
NumbersFizzBuzz, Fibonacci, big factorials, a prime sieve, GCD, Roman numerals, parsing, rounding, random numbers
Collectionsduplicates, sorting by key, grouping, sets, zip and flatten, largest by a measure, stacks and queues
Algorithmsbinary search, quicksort, Towers of Hanoi, permutations, eight queens, a shortest path, matrix products
Files and datawc, 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.

  1. 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.

  2. Collections

    Tasks with lists, dictionaries and sets. List, Dict and Set are shared handles: assigning one does not copy it, clone() does.

  3. 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....

  4. 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; int has no size limit.

  5. 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