Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
20
Task/Variable-size-Get/FreeBASIC/variable-size-get.freebasic
Normal file
20
Task/Variable-size-Get/FreeBASIC/variable-size-get.freebasic
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Dim i As Integer
|
||||
Dim l As Long
|
||||
Dim s As Short
|
||||
Dim b As Byte
|
||||
Print "An integer occupies "; SizeOf(i); " bytes"
|
||||
Print "A long occupies "; SizeOf(l); " bytes"
|
||||
Print "A short occupies "; SizeOf(s); " bytes"
|
||||
Print "A byte occupies "; SizeOf(b); " byte"
|
||||
|
||||
' or use type directly rather than a variable
|
||||
|
||||
Print "A boolean occupies "; SizeOf(Boolean); " byte"
|
||||
Print "A single occupies "; SizeOf(Single); " bytes"
|
||||
Print "A double occupies "; SizeOf(Double); " bytes"
|
||||
|
||||
Print
|
||||
Print "Press any key to quit"
|
||||
Sleep
|
||||
22
Task/Variable-size-Get/Lasso/variable-size-get.lasso
Normal file
22
Task/Variable-size-Get/Lasso/variable-size-get.lasso
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
local(
|
||||
mystring = 'Hello World',
|
||||
myarray = array('one', 'two', 3),
|
||||
myinteger = 1234
|
||||
)
|
||||
|
||||
// size of a string will be a character count
|
||||
#mystring -> size
|
||||
'<br />'
|
||||
|
||||
// size of an array or map will be a count of elements
|
||||
#myarray -> size
|
||||
'<br />'
|
||||
|
||||
// elements within an array can report size
|
||||
#myarray -> get(2) -> size
|
||||
'<br />'
|
||||
|
||||
// integers or decimals does not have sizes
|
||||
//#myinteger -> size // will fail
|
||||
// an integer can however be converted to a string first
|
||||
string(#myinteger) -> size
|
||||
1
Task/Variable-size-Get/Nim/variable-size-get.nim
Normal file
1
Task/Variable-size-Get/Nim/variable-size-get.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
echo "An int contains ", sizeof(int), " bytes."
|
||||
11
Task/Variable-size-Get/Ring/variable-size-get.ring
Normal file
11
Task/Variable-size-Get/Ring/variable-size-get.ring
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
list1 = list(2)
|
||||
list2 = list(4)
|
||||
list3 = list(6)
|
||||
list4 = list(7)
|
||||
list5 = list(5)
|
||||
|
||||
see "Size of list1 is : " + len(list1) + nl
|
||||
see "Size of list2 is : " + len(list2) + nl
|
||||
see "Size of list3 is : " + len(list3) + nl
|
||||
see "Size of list4 is : " + len(list4) + nl
|
||||
see "Size of list5 is : " + len(list5) + nl
|
||||
1
Task/Variable-size-Get/Swift/variable-size-get-1.swift
Normal file
1
Task/Variable-size-Get/Swift/variable-size-get-1.swift
Normal file
|
|
@ -0,0 +1 @@
|
|||
sizeofValue(x)
|
||||
9
Task/Variable-size-Get/Swift/variable-size-get-2.swift
Normal file
9
Task/Variable-size-Get/Swift/variable-size-get-2.swift
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// sizeof and sizeofValue return the size in bytes.
|
||||
println(sizeof(Int))
|
||||
var i: Int = 42
|
||||
println(sizeofValue(i))
|
||||
// The size returned is that of the top level value and does not
|
||||
// include any referenced data. A type like String always returns
|
||||
// the same number, the size of the String struct.
|
||||
println(sizeofValue("Rosetta"))
|
||||
println(sizeofValue("Code"))}
|
||||
Loading…
Add table
Add a link
Reference in a new issue