Logo

Programming-Idioms

History of Idiom 117 > diff from v22 to v23

Edit summary for version 23 by :
New Elixir implementation by user [iamd3vil]

Version 22

2016-02-17, 16:56:07

Version 23

2016-02-18, 16:58:03

Idiom #117 Get list size

Set n to the number of elements of list x.

Idiom #117 Get list size

Set n to the number of elements of list x.

Imports
with Ada.Containers.Vectors;
use Ada.Containers;
Code
N : Count_Type := X.Length;
Code
let n = x.len();

Code
let n = x.len();

Doc URL
http://rustbyexample.com/primitives/array.html
Doc URL
http://rustbyexample.com/primitives/array.html
Code
my $N = @x;
Code
my $N = @x;
Comments bubble
I like to be more explicit, using $N = scalar @x; but some people consider that overly verbose.
Comments bubble
I like to be more explicit, using $N = scalar @x; but some people consider that overly verbose.
Code
n := length(x);
Code
n := length(x);
Comments bubble
x is some type of array.
Comments bubble
x is some type of array.
Code
n := len(x)
Code
n := len(x)
Comments bubble
x is a slice or an array.
Comments bubble
x is a slice or an array.
Doc URL
https://golang.org/pkg/builtin/#len
Doc URL
https://golang.org/pkg/builtin/#len
Demo URL
http://play.golang.org/p/e-8WVe52yM
Demo URL
http://play.golang.org/p/e-8WVe52yM