Skip to contentVarnook
All courses
HollowScriptBeginner

HollowScript: Working with Data

Build the everyday data skills that sit between your first HollowScript programs and real projects: numbers and money, text, decisions, functions, lists, records, maps, sorting, and turning messy text into safe values.

Recommended first: HollowScript Fundamentals. This course builds on it, but you can open it now.

Free to browse. You sign in at the first lesson so your progress is saved.

Free includes 3 learning hours each week, across all courses. If you use them up, running code pauses until Monday at 00:00 UK time; you can still read lessons and edit your code. Longer courses can be spread over several weeks. How weekly limits work.

About this course

HollowScript 0.1.2 preview in WebAssembly

The real HollowScript runtime, a preview release whose details may change, checks and runs your code in the browser. Varnook supplies print, clock and random to every lesson and refuses any other capability a program asks for.

Maintained by Soulstack

Course overview reviewed
Exercise checks verified

Overview review covers the course summary, stated outcomes and final exercise example. Automated verification ran all 18 reference solutions against their checks and confirmed that starter code does not already pass. This is internal verification.

How exercise checks work

What you will be able to do

  • Choose between Int and Float, use div and mod, and keep money as whole pence shown as pounds
  • Clean and test text, then choose outcomes with comparisons, if, else if and match
  • Write functions with typed parameters, including closures that keep private state
  • Build, filter, map and total lists, and count with range and while
  • Model data with records and maps, sort and search it, and parse text safely with Result and the ? operator

Put it into practice

What you will make

Units used between two meter readings

Parse two readings typed as text, pass a failed parse on with the ? operator, and report the units used or the reason a reading cannot be trusted.

Output from the completed course exercise, using its supplied practice data. From Chaining with ?.

Used: 62 kWh

Syllabus

6 modules and 18 lessons. Each lesson is a short read followed by one exercise with checks.

Module 1

Numbers and money

Tell whole numbers from decimals, divide whole numbers properly and handle prices in pence.3 lessons, about 35 min
  1. Numbers, whole and decimalTell Int from Float, predict what an expression gives and read the output.10 min
  2. Whole-number divisionUse div and mod to split whole numbers into how many fit and what is left.10 min
  3. Money and roundingKeep prices as whole pence, round percentages with round, and show pounds with fixed.15 min
Module 2

Text and conditions

Clean and inspect text, ask yes-or-no questions with comparisons, and choose between outcomes with if.3 lessons, about 34 min
  1. Working with textTidy and inspect a string with trim, toUpper, length and endsWith, and join text with interpolation, not `+`.12 min
  2. Comparisons and booleansAsk yes-or-no questions with comparisons and join them with and, or and not.10 min
  3. Choosing with if, else if and elsePick one of several outcomes, and fill a variable from the branch that runs.12 min
Module 3

Functions and choices

Write your own functions, choose between exact values with match, and build functions that remember.3 lessons, about 39 min
  1. Defining functionsWrite a function with typed parameters and a return type, and call it from other code.12 min
  2. match on valuesChoose by exact value with match, share an arm between values, and see why else is needed.12 min
  3. Closures that keep stateBuild a function with private state, and see that two of them are independent.15 min
Module 4

Lists

Build and grow lists, count with range and while, and transform a list with filter, map and reduce.3 lessons, about 46 min
  1. ListsBuild a list, count it, search it and add to it, and see that the original never changes.12 min
  2. Counting with range and whileCount with range when you know how many times, and repeat with while until a goal is reached.16 min
  3. filter, map and reducePass a small function to filter, map and reduce to select, convert and total list items.18 min
Module 5

Records and maps

Bundle related values in records, work through lists of records, and look values up by key in maps.3 lessons, about 40 min
  1. RecordsDeclare a record type, build a value, read its fields and make a changed copy.12 min
  2. Lists of recordsLoop over a list of records, pick out the fields you need and total a column.12 min
  3. MapsLook a value up by key, handle a key that is missing, add entries and count them.16 min
Module 6

Finding and checking

Sort and search lists of records, turn text into numbers safely, and chain steps that can fail.3 lessons, about 44 min
  1. Searching and sortingSort records with a comparison function, find the first match and ask any or all.18 min
  2. Turning text into numbersUse parseInt, handle both of its outcomes with match, and read its two error messages.12 min
  3. Chaining with ?Write a function that returns a Result and uses ? to pass failures on, plus a failure of its own.14 min

After this course

Where to go next

These courses build on what you learn in HollowScript: Working with Data.

Before you start

Some experience from HollowScript Fundamentals is recommended. Times are estimates; practise at your own pace. Every exercise has checks against its brief.

Read how checks, hints and saved work behave. If something is unclear, report a problem with this course and include the lesson link.