Logo

Programming-Idioms

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

Idiom #258 Convert list of strings to list of integers

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

integer, allocatable, dimension(:) :: b
  allocate (b(size(a)))
  read (unit=a,fmt=*) b

This uses Fortran's internal read (i.e. read from character variables).
System.Linq;
var b = a.Select(i => int.Parse(i)).ToList();

New implementation...