// Rimbu Playground - Immutable Collections
import { List, HashMap, HashSet, SortedMap } from '@rimbu/core'
const outputEl = document.getElementById('output')
// Helper to render a section
function renderSection(title, code, result) {
const section = document.createElement('div')
section.className = 'p-4 rounded-xl bg-zinc-800/50 border border-zinc-700/50'
section.innerHTML = `
<p class="text-xs text-zinc-500 uppercase tracking-wider mb-2">${title}</p>
<pre class="text-xs text-indigo-300 mono mb-2 overflow-x-auto"><code>${code}</code></pre>
<pre class="text-sm text-emerald-400 mono overflow-x-auto"><code>→ ${result}</code></pre>
`
outputEl.appendChild(section)
}
// ===== LIST (Immutable Array) =====
console.log('--- Rimbu List ---')
const list = List.of(1, 2, 3, 4, 5)
const appendedList = list.append(6)
const mappedList = list.map(x => x * 2)
renderSection(
'List.of() - Immutable array',
'List.of(1, 2, 3, 4, 5)',
list.toArray().join(', ')
)
renderSection(
'list.append() - Returns new list',
'list.append(6)',
appendedList.toArray().join(', ')
)
renderSection(
'list.map() - Transform values',
'list.map(x => x * 2)',
mappedList.toArray().join(', ')
)
console.log('List:', list.toArray())
console.log('Appended:', appendedList.toArray())