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
1
Task/Null-object/8th/null-object.8th
Normal file
1
Task/Null-object/8th/null-object.8th
Normal file
|
|
@ -0,0 +1 @@
|
|||
null? if "item was null" . then
|
||||
3
Task/Null-object/Axe/null-object.axe
Normal file
3
Task/Null-object/Axe/null-object.axe
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
If P=0
|
||||
Disp "NULL PTR",i
|
||||
End
|
||||
15
Task/Null-object/EchoLisp/null-object.echolisp
Normal file
15
Task/Null-object/EchoLisp/null-object.echolisp
Normal 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
|
||||
20
Task/Null-object/FreeBASIC/null-object.freebasic
Normal file
20
Task/Null-object/FreeBASIC/null-object.freebasic
Normal 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
|
||||
18
Task/Null-object/Lasso/null-object.lasso
Normal file
18
Task/Null-object/Lasso/null-object.lasso
Normal 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
|
||||
21
Task/Null-object/Lily/null-object.lily
Normal file
21
Task/Null-object/Lily/null-object.lily
Normal 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
|
||||
12
Task/Null-object/Lingo/null-object.lingo
Normal file
12
Task/Null-object/Lingo/null-object.lingo
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
put _global.doesNotExist
|
||||
-- <Void>
|
||||
|
||||
put voidP(_global.doesNotExist)
|
||||
-- 1
|
||||
|
||||
x = VOID
|
||||
put x
|
||||
-- <Void>
|
||||
|
||||
put voidP(x)
|
||||
-- 1
|
||||
3
Task/Null-object/Nim/null-object.nim
Normal file
3
Task/Null-object/Nim/null-object.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var s: string = nil
|
||||
|
||||
var ns: string not nil = nil # Compile time error
|
||||
3
Task/Null-object/Oforth/null-object.oforth
Normal file
3
Task/Null-object/Oforth/null-object.oforth
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
null isNull
|
||||
"abcd" isNull
|
||||
: testNull { | a | a ifNull: [ "Variable value is null" println ] ;
|
||||
1
Task/Null-object/PHL/null-object.phl
Normal file
1
Task/Null-object/PHL/null-object.phl
Normal file
|
|
@ -0,0 +1 @@
|
|||
if (obj == null) printf("obj is null!\n");
|
||||
17
Task/Null-object/Phix/null-object.phix
Normal file
17
Task/Null-object/Phix/null-object.phix
Normal 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
|
||||
5
Task/Null-object/Ring/null-object.ring
Normal file
5
Task/Null-object/Ring/null-object.ring
Normal 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
|
||||
3
Task/Null-object/Sidef/null-object-1.sidef
Normal file
3
Task/Null-object/Sidef/null-object-1.sidef
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var undefined; # initialized with an implicit nil
|
||||
say undefined==nil; # true
|
||||
say defined(nil) # false
|
||||
3
Task/Null-object/Sidef/null-object-2.sidef
Normal file
3
Task/Null-object/Sidef/null-object-2.sidef
Normal 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
|
||||
2
Task/Null-object/Swift/null-object-1.swift
Normal file
2
Task/Null-object/Swift/null-object-1.swift
Normal 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
|
||||
5
Task/Null-object/Swift/null-object-2.swift
Normal file
5
Task/Null-object/Swift/null-object-2.swift
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
if let v = opt {
|
||||
println("There is some value: \(v)")
|
||||
} else {
|
||||
println("There is no value")
|
||||
}
|
||||
9
Task/Null-object/Ursa/null-object.ursa
Normal file
9
Task/Null-object/Ursa/null-object.ursa
Normal 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
|
||||
1
Task/Null-object/Wart/null-object.wart
Normal file
1
Task/Null-object/Wart/null-object.wart
Normal file
|
|
@ -0,0 +1 @@
|
|||
(not nil)
|
||||
11
Task/Null-object/jq/null-object.jq
Normal file
11
Task/Null-object/jq/null-object.jq
Normal 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" # => # Ничего
|
||||
Loading…
Add table
Add a link
Reference in a new issue