Data update

This commit is contained in:
Ingy döt Net 2025-08-11 18:05:26 -07:00
parent 4d5544505c
commit 4924dd0264
3073 changed files with 55820 additions and 4408 deletions

View file

@ -1,6 +1,9 @@
Base.start(ll::LinkedList) = ll.head
Base.done(ll::LinkedList{T}, st::AbstractNode{T}) where T = st isa EmptyNode
Base.next(ll::LinkedList{T}, st::AbstractNode{T}) where T = st.data, st.next
Base.iterate(ll::LinkedList) = iterate(ll, ll.head)
Base.iterate(::LinkedList, st::Node) = st.data, st.next
Base.iterate(::LinkedList, ::EmptyNode) = nothing
Base.length(ll::LinkedList) = 1 + length(ll.next)
Base.length(ll::EmptyNode) = 0
Base.eltype(::LinkedList{T}) where {T} = T
lst = LinkedList{Int}()
push!(lst, 1)

View file

@ -0,0 +1,14 @@
require "list"
local fmt = require "fmt"
-- Create a singly-linked list containing the first 50 positive integers.
local s = slist.of(range(1, 50):unpack())
-- Now traverse and print them in tabular form.
local node = s:node(1)
local count = 0
while node do
fmt.write("%4d ", node.value)
node = node.next
if ++count % 10 == 0 then print() end
end