Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
2
Task/Array-length/ArkScript/array-length.ark
Normal file
2
Task/Array-length/ArkScript/array-length.ark
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(assert (= (len []) 0) "len of empty array is 0")
|
||||
(assert (= (len [1 2 3 4]) 4) "len of array is 4")
|
||||
1
Task/Array-length/DuckDB/array-length.duckdb
Normal file
1
Task/Array-length/DuckDB/array-length.duckdb
Normal file
|
|
@ -0,0 +1 @@
|
|||
select length( ['apple', 'orange' ] ) as length;
|
||||
|
|
@ -1,38 +1,3 @@
|
|||
\\ A is a pointer to array
|
||||
A=("Apple", "Orange")
|
||||
Print Len(A)=2 ' True
|
||||
Print Dimension(A, 0) ' LBound (0 or 1), here 0
|
||||
Print Dimension(A) ' No of Dimensions 1
|
||||
Print Dimension(A, 1) ' for 1 dimension array this is also Length=2
|
||||
\\ A$( ) is an Array (not a pointer to array)
|
||||
Dim Base 1, A$(2)
|
||||
A$(1)="Apple", "Orange"
|
||||
Print Dimension(A$(), 0) ' LBound (0 or 1), here 1
|
||||
Print Dimension(A$()) ' No of Dimensions 1
|
||||
Print Dimension(A$(), 1) ' for 1 dimension array this is also Length=2
|
||||
Link A to B$() ' B$() is a reference to A
|
||||
Print B$(0)=A$(1)
|
||||
Print B$(1)=A$(2)
|
||||
Dim C$()
|
||||
\\ C$() get a copy of B$()
|
||||
C$()=B$()
|
||||
Print C$() ' prints Apple Orange
|
||||
\\ An array can link to a new name as reference, and can change major type
|
||||
\\ here A$() get A() so we can read/store numbers and read/store strings in same array
|
||||
\\ using two names
|
||||
Link A$() to A()
|
||||
\\ An array pointer can point to another array
|
||||
A=A()
|
||||
Print Dimension(A, 0) ' LBound (0 or 1), here 1 (was 0)
|
||||
\\ Because B$() is reference of A:
|
||||
Print Dimension(B$(), 0) ' LBound (0 or 1), here 1 (was 0)
|
||||
Print B$(1)=A$(1)
|
||||
Print B$(2)=A$(2)
|
||||
Print Dimension(C$(), 0) ' LBound (0 or 1), here 0
|
||||
\\ change base preserve items
|
||||
Dim Base 1, C$(Dimension(C$(), 1))
|
||||
Print Dimension(C$(), 0) ' LBound (0 or 1), here 1 (was 0)
|
||||
Print C$() ' prints Apple Orange
|
||||
Print Len(C$()) ' Len return all items of an array - can be 0
|
||||
Dim K(1,1,1,1,1,1) ' Maximum 10 dimensions
|
||||
Print Len(K()=1 ' True
|
||||
|
|
|
|||
4
Task/Array-length/Maxima/array-length.maxima
Normal file
4
Task/Array-length/Maxima/array-length.maxima
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
length(["apple","orange"]);
|
||||
fruits: matrix(["apple","orange"],["banana","pear"])$
|
||||
length(fruits);
|
||||
length(list_matrix_entries(fruits));
|
||||
1
Task/Array-length/TAV/array-length.tav
Normal file
1
Task/Array-length/TAV/array-length.tav
Normal file
|
|
@ -0,0 +1 @@
|
|||
print ('apple', 'orange').Count
|
||||
1
Task/Array-length/Tcl/array-length-1.tcl
Normal file
1
Task/Array-length/Tcl/array-length-1.tcl
Normal file
|
|
@ -0,0 +1 @@
|
|||
set mylist { item1 item2 item3 }
|
||||
1
Task/Array-length/Tcl/array-length-2.tcl
Normal file
1
Task/Array-length/Tcl/array-length-2.tcl
Normal file
|
|
@ -0,0 +1 @@
|
|||
set furniture "chair table lamp sofa bed desk"
|
||||
5
Task/Array-length/Tcl/array-length-3.tcl
Normal file
5
Task/Array-length/Tcl/array-length-3.tcl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
set paths [split "/sbin:/bin:/usr/bin:/usr/local/bin:$home/bin" ":"]
|
||||
|
||||
foreach p $paths {
|
||||
puts "$p"
|
||||
}
|
||||
2
Task/Array-length/Tcl/array-length-4.tcl
Normal file
2
Task/Array-length/Tcl/array-length-4.tcl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
set A {}
|
||||
set B [list]
|
||||
1
Task/Array-length/Tcl/array-length-5.tcl
Normal file
1
Task/Array-length/Tcl/array-length-5.tcl
Normal file
|
|
@ -0,0 +1 @@
|
|||
set var 5 ;# ($var is the string "5", or the integer 5 , or a list with one item {5} )
|
||||
5
Task/Array-length/Tcl/array-length-6.tcl
Normal file
5
Task/Array-length/Tcl/array-length-6.tcl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
set len [llength "Apples Oranges"] ;# 2
|
||||
set len [llength {Apples Oranges}] ;# 2
|
||||
set fruit { apples oranges cherries bananas}
|
||||
set len [llength $fruit]
|
||||
puts stdout "($len) : $fruit"
|
||||
10
Task/Array-length/Tcl/array-length-7.tcl
Normal file
10
Task/Array-length/Tcl/array-length-7.tcl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# The ''lindex'' command returns a single item at a given index of a list
|
||||
|
||||
set c [lindex $fruit 2] ;# "cherries" (0-based index)
|
||||
|
||||
# The ''lrange'' command returns a given range of items from a list, as a new list.
|
||||
|
||||
set A [lrange $fruit 0 2] ;# {apples oranges cherries} (list)
|
||||
|
||||
# An empty list is not necessarily an empty string:
|
||||
set var { } ;# $var => " ", but [llength $var] => 0
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
;# not recommended:
|
||||
set mylistA {apple orange} ;# actually a string
|
||||
set mylistA "Apple Orange" ;# same - this works only for simple cases
|
||||
|
||||
set lenA [llength $mylistA]
|
||||
puts "$mylistA : $lenA"
|
||||
|
||||
# better: to build a list, use 'list' and/or 'lappend':
|
||||
set mylistB [list apple orange "red wine" {green frog}]
|
||||
lappend mylistB "blue bird"
|
||||
|
||||
set lenB [llength $mylistB]
|
||||
puts "$mylistB : $lenB"
|
||||
Loading…
Add table
Add a link
Reference in a new issue