Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Perl

Idiom #258 Convert list of strings to list of integers

Convert the string values from list a into a list of integers b.

@b = map { $_ += 0 } @a

Technically, Perl doesn't have types, however, deep in its guts it does know if a variable has been used in a string context. This is for interacting with other languages and protocols. The '+=0' 'numifies' the entry.
System.Linq;
var b = a.Select(i => int.Parse(i)).ToList();

New implementation...