Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1 @@
null? if "item was null" . then

View file

@ -0,0 +1,3 @@
If P=0
Disp "NULL PTR",i
End

View file

@ -0,0 +1,15 @@
null → null
() → null
(null? 3) → #f
(!null? 4) → #t
(null? null) → #t
;; careful - null is not false :
(if null 'OUI 'NON) → OUI
;; usual usage : recursion on lists until (null? list)
(define (f list)
(when (!null? list)
(write (first list)) (f (rest list))))
(f '( a b c)) → a b c

View file

@ -0,0 +1,20 @@
'FB 1.05.0 Win64
' FreeBASIC does not have a NULL keyword but it's possible to create one using a macro
#Define NULL CPtr(Any Ptr, 0) '' Any Ptr is implicitly convertible to pointers of other types
Type Dog
name As String
age As Integer
End Type
Dim d As Dog Ptr = New Dog
d->Name = "Rover"
d->Age = 5
Print d->Name, d->Age
Delete d
d = NULL '' guard against 'd' being used accidentally in future
' in practice many FB developers would simply have written: d = 0 above
Sleep

View file

@ -0,0 +1,18 @@
local(x = string, y = null)
#x->isA(::null)
// 0 (false)
#y->isA(::null)
// 1 (true)
#x == null
// false
#y == null
//true
#x->type == 'null'
// false
#y->type == 'null'
//true

View file

@ -0,0 +1,21 @@
enum class Option[A] {
Some(A)
None
}
# Only variables of class Option can be assigned to None.
# Type: Option[integer]
var v = Some(10)
# Valid: v is an Option, and any Option can be assigned to None
v = None
# Invalid! v is an Option[integer], not just a plain integer.
v = 10
# Type: integer
var w = 10
# Invalid! Likewise, w is an integer, not an Option.
w = None

View file

@ -0,0 +1,12 @@
put _global.doesNotExist
-- <Void>
put voidP(_global.doesNotExist)
-- 1
x = VOID
put x
-- <Void>
put voidP(x)
-- 1

View file

@ -0,0 +1,3 @@
var s: string = nil
var ns: string not nil = nil # Compile time error

View file

@ -0,0 +1,3 @@
null isNull
"abcd" isNull
: testNull { | a | a ifNull: [ "Variable value is null" println ] ;

View file

@ -0,0 +1 @@
if (obj == null) printf("obj is null!\n");

View file

@ -0,0 +1,17 @@
type nullableString(object o)
return string(o) or o=NULL
end type
nullableString s
s = "hello"
s = NULL
--s = 1 -- error
--s = {1,2,3} -- error
type nullableSequence(object o)
return sequence(o) or o=NULL
end type
nullableSequence q
q = {1,2,3}
q = "string" -- fine (strings are a subset of sequences)
q = NULL
--q = 1 -- error

View file

@ -0,0 +1,5 @@
see isnull(5) + nl + # print 0
isnull("hello") + nl + # print 0
isnull([1,3,5]) + nl + # print 0
isnull("") + nl + # print 1
isnull("NULL") # print 1

View file

@ -0,0 +1,3 @@
var undefined; # initialized with an implicit nil
say undefined==nil; # true
say defined(nil) # false

View file

@ -0,0 +1,3 @@
var null_obj = null; # initialize with a null value
say null_obj.is_a(null); # true
say defined(null_obj); # true

View file

@ -0,0 +1,2 @@
var opt : Int? = nil // use "nil" to represent no value
opt = 5 // or simply assign a value to the optional type

View file

@ -0,0 +1,5 @@
if let v = opt {
println("There is some value: \(v)")
} else {
println("There is no value")
}

View file

@ -0,0 +1,9 @@
# the type at declaration doesn't matter
decl int x
set x null
if (= x null)
out "x is null" endl console
else
out "x is not null" endl console
end if

View file

@ -0,0 +1 @@
(not nil)

View file

@ -0,0 +1,11 @@
null|type # => "null"
null == false # => false
null == null # => true
empty|type # => # i.e. nothing (as in, nada)
empty == empty # => # niente
empty == "black hole" # => # Ничего