Urgent.News

What's breaking now, across thousands of outlets.

Tech

Raku: a language that counts to infinity (Part 2)

In this part, let's look at infinite sequences from another angle: let's start collecting the values. First of all, Raku has a pair of built-in routines gather and take . They are useful when you need to collect data that's computed along the way. For example: my @data = gather { for ^50 { my $value = 100.rand.Int; take $value if 45 < $value < 55; } } say @data ; The program prints a few random…

Raku, a programming language, allows for the manipulation of infinite sequences through the use of built-in routines gather and take. These routines enable the collection of data computed along the way, even when dealing with infinite sequences. The language's approach to infinity makes the code clearer and more straightforward, as it focuses on applying actions to an infinite sequence and then taking only the necessary elements.

Examples provided include generating random numbers within a specific range, creating Pascal's triangle, and working with infinite sequences in various mathematical operations.

Brief written by urgent.news from Dev.to's own syndicated text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Why Module Federation — Building an Enterprise MFE Platform (Part 1)

This series walks through an actual enterprise microfrontend platform, end to end: one Host shell, three shared platform microfrontends, a manifest-driven mechanism for mounting any number of…

  • Enterprise microfrontend platform built using Webpack 5 Module Federation
  • Host ships with empty list of remote apps, fetches info from manifest
  • Teams deploy pages by updating manifest, no Host rebuild required

More from Sunday 30 August →