# Idiom #258 Convert list of strings to list of integers

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

``let b: Vec<i64> = a.iter().map(|x| x.parse::<i64>().unwrap()).collect();``
``````let b: Vec<i32> = a.iter().flat_map(|s| s.parse().ok()).collect();
``````
``System.Linq;``
``var b = a.Select(i => int.Parse(i)).ToList();``
``var b = a.map(int.parse).toList();``
``integer, allocatable, dimension(:) :: b``
``````  allocate (b(size(a)))
``````
``import "strconv"``
``````b := make([]int, len(a))
var err error
for i, s := range a {
b[i], err = strconv.Atoi(s)
if err != nil {
return err
}
}``````
``let b = a.map(Number)``
``````import java.util.List;
import java.util.stream.Collectors;``````
``````List<Integer> b = items.stream()
.map(Integer::parseInt)
.collect(Collectors.toList());``````
``import java.util.ArrayList;``
``````ArrayList<Integer> b = new ArrayList<>();
for(String value : a) {
}``````
``uses classes, systutils, fgl;``
``````var
a: TStringList;
b: specialize TList<Integer>;
...
for i := 0 to a.count-1 do b.add(IntToStr(a[i]));``````
``@b = map { \$_ += 0 } @a``
``b = [int(elem) for elem in a]``
``b = a.map(&:to_i)``
``````For i = LBound(a) To UBound(a)
b(i) = CInt(a(i))
Next``````

programming-idioms.org