Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

length

length( 
laot_arg 
) 
=> x_result / 0

Description

Determines the length of a list, array, association table, or string.

The time taken to compute the length depends on the type of object. For example,

List

Time taken to compute the length of a list is proportional to the number of items in the list.

Array

Time taken to compute the length of an array is constant.

Association table

Time taken to compute the length of an association table is constant.

String

Time taken to compute the length of a string is proportional to the number of characters in the string.

Arguments

laot_arg

SKILL list, array, association table, or string.

Value Returned

x_result

Length of the laot_arg object. (The length is either the number of elements in the list, string, or array or the number of key/value pairs in the association table).

0

laot_arg is nil or an empty array or table.

Examples

length( '(a b c d) )             
=> 4
z = '(1 2 3)                     
=> (1 2 3)
length( z )                      
=> 3
length("hello")
=> 5
declare(a[11])
length( a )
=> 11
myTable = makeTable( "atable" 0) 
=> table:atable
myTable[ 'one] = "blue"          
=> "blue"
myTable[ "two"] = '(red)         
=> (r e d)
length(myTable)                  
=> 2

Related Topics

list


Return to top
 ⠀
X