How to resolve the algorithm Variable size/Get step by step in the Raku programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Variable size/Get step by step in the Raku programming language
Table of Contents
Problem Statement
Demonstrate how to get the size of a variable. See also: Host introspection
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Variable size/Get step by step in the Raku programming language
Source code in the raku programming language
# Textual strings are measured in characters (graphemes)
my $string = "abc";
# Arrays are measured in elements.
say $string.chars; # 3
my @array = 1..5;
say @array.elems; # 5
# Buffers may be viewed either as a byte-string or as an array of elements.
my $buffer = '#56997; means "four dragons".'.encode('utf8');
say $buffer.bytes; # 26
say $buffer.elems; # 26
You may also check:How to resolve the algorithm Loops/For step by step in the Crystal programming language
You may also check:How to resolve the algorithm Sorting algorithms/Patience sort step by step in the Clojure programming language
You may also check:How to resolve the algorithm HTTPS/Authenticated step by step in the Clojure programming language
You may also check:How to resolve the algorithm Higher-order functions step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm Recaman's sequence step by step in the PL/M programming language