Larzscript Course · Lesson 7 of 15

Modules & the Package Ecosystem

Larz covers Larzscript's module system: import a package by name, give it a short alias with as, and call its functions through that alias - a first look at the real 160+ package ecosystem.

import and namespacing

Import a module by name, give it an alias with as, then call its functions through that alias:

import "mathx" as mathx

print(mathx.is_prime(97))
print(mathx.fib(10))
Output
true
55

stack and queue

mathx is just one of 160+ packages. stack and queue are two more - a real last-in-first-out and first-in-first-out, ready to import the same way:

import "stack" as stack
import "queue" as queue

let s = stack.new()
stack.push(s, "a")
stack.push(s, "b")
print(stack.pop(s))

let q = queue.new()
queue.enqueue(q, 1)
queue.enqueue(q, 2)
print(queue.dequeue(q))
Output
b
1

Every snippet on this page is run through the real larzscript interpreter, not hand-typed โ€” what you see in the Output blocks is the actual output, for everything shown: importing a module, aliasing it, and calling its functions.

← Lesson 6Course syllabusGitHub