Skip to main content

fromTo

fromTo(a: Number, b: Number) : List<Number>

A list of numbers in a range can be constructed with fromTo(a, b), which equals the list of numbers starting from a and ending with b. For example,fromTo(1, 3) is the same as [1, 2, 3]. If the second argument is smaller than the first, as in fromTo(3, 1), the returned value is the empty list.

fromTo(a: IpAddress, b: IpAddress) : List<IpAddress>

A list of IP addresses in a range can be constructed with fromTo(a, b), which equals the list of IP addresses starting from a and ending with b. For example:

  • fromTo(ipAddress("1.2.2.254"), ipAddress("1.2.3.1")) is same as [1.2.2.254, 1.2.2.255, 1.2.3.0, 1.2.3.1]
  • fromTo(ipAddress("2001:0db8:85a3:0000:0000:8a2e:0370:fffe"), ipAddress("2001:0db8:85a3:0000:0000:8a2e:0371:001")) is same as [2001:0db8:85a3:0000:0000:8a2e:0370:fffe, "2001:0db8:85a3:0000:0000:8a2e:0370:ffff, 2001:0db8:85a3:0000:0000:8a2e:0371:0, 2001:0db8:85a3:0000:0000:8a2e:0371:1].

If the second argument is smaller than the first, as in fromTo(ipAddress("1.2.2.4"), ipAddress("0.0.0.0")), the returned value is the empty list.

This function will raise an error:

  • if a and b are not of same IP address family. For example, fromTo(ipAddress("1.2.2.254"), ipAddress ("2001:0db8:85a3:0000:0000:8a2e:0370:fffe")).
  • if number of IP addressese between a and b is 2147483647 or greater.

See also

Types

Functions