Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Null-object/00-META.yaml
Normal file
5
Task/Null-object/00-META.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Simple
|
||||
from: http://rosettacode.org/wiki/Null_object
|
||||
note: Basic language learning
|
||||
12
Task/Null-object/00-TASK.txt
Normal file
12
Task/Null-object/00-TASK.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
'''Null''' (or '''nil''') is the computer science concept of an undefined or unbound object.
|
||||
Some languages have an explicit way to access the null object, and some don't.
|
||||
Some languages distinguish the null object from [[undefined values]], and some don't.
|
||||
|
||||
|
||||
;Task:
|
||||
Show how to access null in your language by checking to see if an object is equivalent to the null object.
|
||||
|
||||
|
||||
''This task is not about whether a variable is defined. The task is about "null"-like values in various languages, which may or may not be related to the defined-ness of variables in your language.''
|
||||
<br><br>
|
||||
|
||||
8
Task/Null-object/11l/null-object.11l
Normal file
8
Task/Null-object/11l/null-object.11l
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
F f([Int]? &a)
|
||||
I a != N
|
||||
a.append(1)
|
||||
|
||||
f(N)
|
||||
[Int] arr
|
||||
f(&arr)
|
||||
print(arr)
|
||||
8
Task/Null-object/6502-Assembly/null-object.6502
Normal file
8
Task/Null-object/6502-Assembly/null-object.6502
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
lda pointer ;a zero-page address that holds the low byte of a pointer variable.
|
||||
CMP #$FF
|
||||
BNE .continue
|
||||
lda pointer+1
|
||||
CMP #$FF
|
||||
BNE .continue
|
||||
RTS ;return without doing anything
|
||||
.continue
|
||||
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
|
||||
46
Task/Null-object/AArch64-Assembly/null-object.aarch64
Normal file
46
Task/Null-object/AArch64-Assembly/null-object.aarch64
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* ARM assembly AARCH64 Raspberry PI 3B */
|
||||
/* program nullobj64.s */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes file */
|
||||
/*******************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeConstantesARM64.inc"
|
||||
/*******************************************/
|
||||
/* Initialized data */
|
||||
/*******************************************/
|
||||
.data
|
||||
szCarriageReturn: .asciz "\n"
|
||||
szMessResult: .asciz "Value is null.\n" // message result
|
||||
|
||||
qPtrObjet: .quad 0 // objet pointer
|
||||
/*******************************************/
|
||||
/* UnInitialized data */
|
||||
/*******************************************/
|
||||
.bss
|
||||
/*******************************************/
|
||||
/* code section */
|
||||
/*******************************************/
|
||||
.text
|
||||
.global main
|
||||
main: // entry of program
|
||||
|
||||
ldr x0,qAdrqPtrObjet // load pointer address
|
||||
ldr x0,[x0] // load pointer value
|
||||
cbnz x0,100f // is null ?
|
||||
ldr x0,qAdrszMessResult // yes -> display message
|
||||
bl affichageMess
|
||||
|
||||
100: // standard end of the program
|
||||
mov x0,0 // return code
|
||||
mov x8,EXIT // request to exit program
|
||||
svc 0 // perform the system call
|
||||
|
||||
qAdrszMessResult: .quad szMessResult
|
||||
qAdrszCarriageReturn: .quad szCarriageReturn
|
||||
qAdrqPtrObjet: .quad qPtrObjet
|
||||
/********************************************************/
|
||||
/* File Include fonctions */
|
||||
/********************************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly */
|
||||
.include "../includeARM64.inc"
|
||||
19
Task/Null-object/ALGOL-68/null-object.alg
Normal file
19
Task/Null-object/ALGOL-68/null-object.alg
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
REF STRING no result = NIL;
|
||||
STRING result := "";
|
||||
|
||||
IF no result :=: NIL THEN print(("no result :=: NIL", new line)) FI;
|
||||
IF result :/=: NIL THEN print(("result :/=: NIL", new line)) FI;
|
||||
|
||||
IF no result IS NIL THEN print(("no result IS NIL", new line)) FI;
|
||||
IF result ISNT NIL THEN print(("result ISNT NIL", new line)) FI;
|
||||
|
||||
COMMENT using the UNESCO/IFIP/WG2.1 ALGOL 68 character set
|
||||
result := °;
|
||||
IF REF STRING(result) :≠: ° THEN print(("result ≠ °", new line)) FI;
|
||||
END COMMENT
|
||||
|
||||
# Note the following gotcha: #
|
||||
|
||||
REF STRING var := NIL;
|
||||
IF var ISNT NIL THEN print(("The address of var ISNT NIL",new line)) FI;
|
||||
IF var IS REF STRING(NIL) THEN print(("The address of var IS REF STRING(NIL)",new line)) FI
|
||||
10
Task/Null-object/ALGOL-W/null-object.alg
Normal file
10
Task/Null-object/ALGOL-W/null-object.alg
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
begin
|
||||
% declare a record type - will be accessed via references %
|
||||
record R( integer f1, f2, f3 );
|
||||
% declare a reference to a R instance %
|
||||
reference(R) refR;
|
||||
% assign null to the reference %
|
||||
refR := null;
|
||||
% test for a null reference - will write "refR is null" %
|
||||
if refR = null then write( "refR is null" ) else write( "not null" );
|
||||
end.
|
||||
8
Task/Null-object/APL/null-object.apl
Normal file
8
Task/Null-object/APL/null-object.apl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
⍝⍝ GNU APL
|
||||
]help ⍬
|
||||
niladic function: Z ← ⍬ (Zilde)
|
||||
Zilde is the empty numeric vector (aka. ⍳0)
|
||||
Not a function but rather an alias for the empty
|
||||
vector:
|
||||
⍬≡⍳0
|
||||
1
|
||||
60
Task/Null-object/ARM-Assembly/null-object.arm
Normal file
60
Task/Null-object/ARM-Assembly/null-object.arm
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program nullobj.s */
|
||||
|
||||
/* Constantes */
|
||||
.equ STDIN, 0 @ Linux input console
|
||||
.equ STDOUT, 1 @ Linux output console
|
||||
.equ EXIT, 1 @ Linux syscall
|
||||
.equ READ, 3 @ Linux syscall
|
||||
.equ WRITE, 4 @ Linux syscall
|
||||
|
||||
/* Initialized data */
|
||||
.data
|
||||
szCarriageReturn: .asciz "\n"
|
||||
szMessResult: .asciz "Value is null.\n" @ message result
|
||||
|
||||
iPtrObjet: .int 0 @ objet pointer
|
||||
|
||||
/* UnInitialized data */
|
||||
.bss
|
||||
|
||||
/* code section */
|
||||
.text
|
||||
.global main
|
||||
main: @ entry of program
|
||||
|
||||
ldr r0,iAdriPtrObjet @ load pointer address
|
||||
ldr r0,[r0] @ load pointer value
|
||||
cmp r0,#0 @ is null ?
|
||||
ldreq r0,iAdrszMessResult @ yes -> display message
|
||||
bleq affichageMess
|
||||
|
||||
|
||||
100: @ standard end of the program
|
||||
mov r0, #0 @ return code
|
||||
pop {fp,lr} @ restaur 2 registers
|
||||
mov r7, #EXIT @ request to exit program
|
||||
svc 0 @ perform the system call
|
||||
|
||||
iAdrszMessResult: .int szMessResult
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
iAdriPtrObjet: .int iPtrObjet
|
||||
/******************************************************************/
|
||||
/* display text with size calculation */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the message */
|
||||
affichageMess:
|
||||
push {r0,r1,r2,r7,lr} @ save registres
|
||||
mov r2,#0 @ counter length
|
||||
1: @ loop length calculation
|
||||
ldrb r1,[r0,r2] @ read octet start position + index
|
||||
cmp r1,#0 @ if 0 its over
|
||||
addne r2,r2,#1 @ else add 1 in the length
|
||||
bne 1b @ and loop
|
||||
@ so here r2 contains the length of the message
|
||||
mov r1,r0 @ address message in r1
|
||||
mov r0,#STDOUT @ code to write to the standard output Linux
|
||||
mov r7, #WRITE @ code call system "write"
|
||||
svc #0 @ call systeme
|
||||
pop {r0,r1,r2,r7,lr} @ restaur des 2 registres */
|
||||
bx lr @ return
|
||||
7
Task/Null-object/AWK/null-object.awk
Normal file
7
Task/Null-object/AWK/null-object.awk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/awk -f
|
||||
BEGIN {
|
||||
b=0;
|
||||
print "<"b,length(b)">"
|
||||
print "<"u,length(u)">"
|
||||
print "<"u+0,length(u+0)">";
|
||||
}
|
||||
20
Task/Null-object/Action-/null-object.action
Normal file
20
Task/Null-object/Action-/null-object.action
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
TYPE Object=[
|
||||
BYTE byteData
|
||||
INT intData
|
||||
CARD cardData]
|
||||
|
||||
PROC IsNull(Object POINTER ptr)
|
||||
IF ptr=0 THEN
|
||||
PrintE("Object is null")
|
||||
ELSE
|
||||
PrintE("Object is not null")
|
||||
FI
|
||||
RETURN
|
||||
|
||||
PROC Main()
|
||||
Object a
|
||||
Object POINTER ptr1=a,ptr2=0
|
||||
|
||||
IsNull(ptr1)
|
||||
IsNull(ptr2)
|
||||
RETURN
|
||||
2
Task/Null-object/ActionScript/null-object.as
Normal file
2
Task/Null-object/ActionScript/null-object.as
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
if (object == null)
|
||||
trace("object is null");
|
||||
5
Task/Null-object/Ada/null-object.ada
Normal file
5
Task/Null-object/Ada/null-object.ada
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
with Ada.Text_Io;
|
||||
|
||||
if Object = null then
|
||||
Ada.Text_Io.Put_line("object is null");
|
||||
end if;
|
||||
5
Task/Null-object/AmigaE/null-object.amiga
Normal file
5
Task/Null-object/AmigaE/null-object.amiga
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
DEF x : PTR TO object
|
||||
-> ...
|
||||
IF object <> NIL
|
||||
-> ...
|
||||
ENDIF
|
||||
7
Task/Null-object/AppleScript/null-object.applescript
Normal file
7
Task/Null-object/AppleScript/null-object.applescript
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
if x is missing value then
|
||||
display dialog "x is missing value"
|
||||
end if
|
||||
|
||||
if x is null then
|
||||
display dialog "x is null"
|
||||
end if
|
||||
5
Task/Null-object/Applesoft-BASIC/null-object.basic
Normal file
5
Task/Null-object/Applesoft-BASIC/null-object.basic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
TRUE = 1 : FALSE = 0
|
||||
NULL = TRUE
|
||||
IF NULL THEN PRINT "NULL"
|
||||
NULL = FALSE
|
||||
IF NOT NULL THEN PRINT "NOT NULL"
|
||||
3
Task/Null-object/Arturo/null-object.arturo
Normal file
3
Task/Null-object/Arturo/null-object.arturo
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
v: null
|
||||
|
||||
if v=null -> print "got NULL!"
|
||||
2
Task/Null-object/AutoHotkey/null-object.ahk
Normal file
2
Task/Null-object/AutoHotkey/null-object.ahk
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
If (object == null)
|
||||
MsgBox, object is null
|
||||
2
Task/Null-object/AutoIt/null-object.autoit
Normal file
2
Task/Null-object/AutoIt/null-object.autoit
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Local $object = Null
|
||||
If $object = Null Then MsgBox(0, "NULL", "Object is null")
|
||||
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
|
||||
13
Task/Null-object/BBC-BASIC/null-object.basic
Normal file
13
Task/Null-object/BBC-BASIC/null-object.basic
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
PROCtestobjects
|
||||
END
|
||||
|
||||
DEF PROCtestobjects
|
||||
PRIVATE a(), b(), s{}, t{}
|
||||
DIM a(123)
|
||||
DIM s{a%, b#, c$}
|
||||
|
||||
IF !^a() <= 1 PRINT "a() is null" ELSE PRINT "a() is not null"
|
||||
IF !^b() <= 1 PRINT "b() is null" ELSE PRINT "b() is not null"
|
||||
IF !^s{} <= 1 PRINT "s{} is null" ELSE PRINT "s{} is not null"
|
||||
IF !^t{} <= 1 PRINT "t{} is null" ELSE PRINT "t{} is not null"
|
||||
ENDPROC
|
||||
1
Task/Null-object/Babel/null-object.pb
Normal file
1
Task/Null-object/Babel/null-object.pb
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ nil { nil? } { "Whew!\n" } { "Something is terribly wrong!\n" } ifte << }
|
||||
3
Task/Null-object/Bracmat/null-object.bracmat
Normal file
3
Task/Null-object/Bracmat/null-object.bracmat
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
a:?x*a*?z {assigns 1 to x and to z}
|
||||
a:?x+a+?z {assigns 0 to x and to z}
|
||||
a:?x a ?z {assigns "" (or (), which is equivalent) to x and to z}
|
||||
5
Task/Null-object/C++/null-object-1.cpp
Normal file
5
Task/Null-object/C++/null-object-1.cpp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
if (object == 0) {
|
||||
std::cout << "object is null";
|
||||
}
|
||||
12
Task/Null-object/C++/null-object-2.cpp
Normal file
12
Task/Null-object/C++/null-object-2.cpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include <iostream>
|
||||
#include <optional>
|
||||
|
||||
std::optional<int> maybeInt()
|
||||
|
||||
int main()
|
||||
{
|
||||
std::optional<int> maybe = maybeInt();
|
||||
|
||||
if(!maybe)
|
||||
std::cout << "object is null\n";
|
||||
}
|
||||
9
Task/Null-object/C++/null-object-3.cpp
Normal file
9
Task/Null-object/C++/null-object-3.cpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
int *p = nullptr;
|
||||
...
|
||||
if (p == nullptr){
|
||||
// do some thing
|
||||
}
|
||||
//or just
|
||||
if (p){
|
||||
// do some thing
|
||||
}
|
||||
2
Task/Null-object/C-sharp/null-object-1.cs
Normal file
2
Task/Null-object/C-sharp/null-object-1.cs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
if (foo == null)
|
||||
Console.WriteLine("foo is null");
|
||||
2
Task/Null-object/C-sharp/null-object-2.cs
Normal file
2
Task/Null-object/C-sharp/null-object-2.cs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
int? x = 12;
|
||||
x = null;
|
||||
8
Task/Null-object/C-sharp/null-object-3.cs
Normal file
8
Task/Null-object/C-sharp/null-object-3.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Console.WriteLine(name ?? "Name not specified");
|
||||
|
||||
//Without the null coalescing operator, this would instead be written as:
|
||||
//if(name == null){
|
||||
// Console.WriteLine("Name not specified");
|
||||
//}else{
|
||||
// Console.WriteLine(name);
|
||||
//}
|
||||
11
Task/Null-object/C/null-object.c
Normal file
11
Task/Null-object/C/null-object.c
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char *object = 0;
|
||||
|
||||
if (object == NULL) {
|
||||
puts("object is null");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
43
Task/Null-object/COBOL/null-object.cobol
Normal file
43
Task/Null-object/COBOL/null-object.cobol
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
identification division.
|
||||
program-id. null-objects.
|
||||
remarks. test with cobc -x -j null-objects.cob
|
||||
|
||||
data division.
|
||||
working-storage section.
|
||||
01 thing-not-thing usage pointer.
|
||||
|
||||
*> call a subprogram
|
||||
*> with one null pointer
|
||||
*> an omitted parameter
|
||||
*> and expect void return (callee returning omitted)
|
||||
*> and do not touch default return-code (returning nothing)
|
||||
procedure division.
|
||||
call "test-null" using thing-not-thing omitted returning nothing
|
||||
goback.
|
||||
end program null-objects.
|
||||
|
||||
*> Test for pointer to null (still a real thing that takes space)
|
||||
*> and an omitted parameter, (call frame has placeholder)
|
||||
*> and finally, return void, (omitted)
|
||||
identification division.
|
||||
program-id. test-null.
|
||||
|
||||
data division.
|
||||
linkage section.
|
||||
01 thing-one usage pointer.
|
||||
01 thing-two pic x.
|
||||
|
||||
procedure division using
|
||||
thing-one
|
||||
optional thing-two
|
||||
returning omitted.
|
||||
|
||||
if thing-one equal null then
|
||||
display "thing-one pointer to null" upon syserr
|
||||
end-if
|
||||
|
||||
if thing-two omitted then
|
||||
display "no thing-two was passed" upon syserr
|
||||
end-if
|
||||
goback.
|
||||
end program test-null.
|
||||
3
Task/Null-object/Chapel/null-object.chapel
Normal file
3
Task/Null-object/Chapel/null-object.chapel
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
class C { };
|
||||
var c:C; // is nil
|
||||
writeln(if c == nil then "nil" else "something");
|
||||
2
Task/Null-object/Clojure/null-object-1.clj
Normal file
2
Task/Null-object/Clojure/null-object-1.clj
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(let [x nil]
|
||||
(println "Object is" (if (nil? x) "nil" "not nil")))
|
||||
1
Task/Null-object/Clojure/null-object-2.clj
Normal file
1
Task/Null-object/Clojure/null-object-2.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(find (ns-interns *ns*) 'foo)
|
||||
1
Task/Null-object/Clojure/null-object-3.clj
Normal file
1
Task/Null-object/Clojure/null-object-3.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(ns-unmap *ns* 'foo)
|
||||
1
Task/Null-object/Common-Lisp/null-object-1.lisp
Normal file
1
Task/Null-object/Common-Lisp/null-object-1.lisp
Normal file
|
|
@ -0,0 +1 @@
|
|||
(if (condition) (do-this))
|
||||
5
Task/Null-object/Common-Lisp/null-object-2.lisp
Normal file
5
Task/Null-object/Common-Lisp/null-object-2.lisp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(defmethod car* ((arg cons))
|
||||
(car arg))
|
||||
|
||||
(defmethod car* ((arg null))
|
||||
nil)
|
||||
2
Task/Null-object/Common-Lisp/null-object-3.lisp
Normal file
2
Task/Null-object/Common-Lisp/null-object-3.lisp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(defmethod car* ((arg t)) ;; can just be written (defmethod car* (arg) ...)
|
||||
(error "CAR*: ~s is neither a cons nor nil" arg))
|
||||
17
Task/Null-object/Component-Pascal/null-object.pas
Normal file
17
Task/Null-object/Component-Pascal/null-object.pas
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
MODULE ObjectNil;
|
||||
IMPORT StdLog;
|
||||
TYPE
|
||||
Object = POINTER TO ObjectDesc;
|
||||
ObjectDesc = RECORD
|
||||
END;
|
||||
VAR
|
||||
x: Object; (* default initialization to NIL *)
|
||||
|
||||
PROCEDURE DoIt*;
|
||||
BEGIN
|
||||
IF x = NIL THEN
|
||||
StdLog.String("x is NIL");StdLog.Ln
|
||||
END
|
||||
END DoIt;
|
||||
|
||||
END ObjectNil.
|
||||
14
Task/Null-object/Crystal/null-object.crystal
Normal file
14
Task/Null-object/Crystal/null-object.crystal
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
foo : Int32 | Nil = 5 # this variable's type can be Int32 or Nil
|
||||
bar : Int32? = nil # equivalent type to above, but shorter syntax
|
||||
baz : Int32 = 5 # this variable can never be nil
|
||||
|
||||
foo.not_nil! # nothing happens, since 5 is not nil
|
||||
puts "Is foo nil? #{foo.nil?}"
|
||||
foo = nil
|
||||
puts "Now is foo nil? #{foo.nil?}"
|
||||
|
||||
puts "Does bar equal nil? #{bar == nil}"
|
||||
|
||||
puts "Is bar equivalent to nil? #{bar === nil}"
|
||||
|
||||
bar.not_nil! # bar is nil, so an exception is thrown
|
||||
12
Task/Null-object/D/null-object.d
Normal file
12
Task/Null-object/D/null-object.d
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import std.stdio;
|
||||
|
||||
class K {}
|
||||
|
||||
void main() {
|
||||
K k;
|
||||
if (k is null)
|
||||
writeln("k is null");
|
||||
k = new K;
|
||||
if (k !is null)
|
||||
writeln("Now k is not null");
|
||||
}
|
||||
6
Task/Null-object/Delphi/null-object.delphi
Normal file
6
Task/Null-object/Delphi/null-object.delphi
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// the following are equivalent
|
||||
if lObject = nil then
|
||||
...
|
||||
|
||||
if not Assigned(lObject) then
|
||||
...
|
||||
4
Task/Null-object/Dyalect/null-object.dyalect
Normal file
4
Task/Null-object/Dyalect/null-object.dyalect
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
var x = nil
|
||||
if x == nil {
|
||||
//Do something
|
||||
}
|
||||
1
Task/Null-object/E/null-object.e
Normal file
1
Task/Null-object/E/null-object.e
Normal file
|
|
@ -0,0 +1 @@
|
|||
object == null
|
||||
13
Task/Null-object/EMal/null-object.emal
Normal file
13
Task/Null-object/EMal/null-object.emal
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
^|
|
||||
| EMal has the Variable type (and its keyword var) that is the nullable universal supertype.
|
||||
| EMal has the Void type (and its keyword void) that holds only one value: null.
|
||||
| EMal has not nullable types (logic, int, real, text, blob), but null equality is always allowed.
|
||||
|^
|
||||
var a # defaults to null
|
||||
int b # defaults to 0
|
||||
void c # only one allowed value: null
|
||||
writeLine("nullable var equals to not nullable int: " + (a == b)) # allowed, false
|
||||
^| if the data type of a is void we are sure that a is null |^
|
||||
writeLine("type of a equals to Void data type: " + (generic!a == void)) # true
|
||||
writeLine("integer value " + b + " equals to null: " + (b == null)) # allowed, always false
|
||||
writeLine("a void value equals to null: " + (c == null)) # always true
|
||||
15
Task/Null-object/EchoLisp/null-object.l
Normal file
15
Task/Null-object/EchoLisp/null-object.l
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
|
||||
25
Task/Null-object/Ecstasy/null-object.ecstasy
Normal file
25
Task/Null-object/Ecstasy/null-object.ecstasy
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
module NullObject {
|
||||
void run() {
|
||||
@Inject Console console;
|
||||
console.print($"Null value={Null}, Null.toString()={Null.toString()}");
|
||||
|
||||
// String s = Null; // <-- compiler error: cannot assign Null to a String type
|
||||
String? s = Null; // "String?" is shorthand for the union "Nullable|String"
|
||||
String s2 = "test";
|
||||
console.print($"{s=}, {s2=}, {s==s2=}");
|
||||
|
||||
// Int len = s.size; // <-- compiler error: String? does not have a "size" property
|
||||
Int len = s?.size : 0;
|
||||
console.print($"{len=}");
|
||||
|
||||
if (String test ?= s) {
|
||||
// "s" is still Null in this test, we never get here
|
||||
} else {
|
||||
s = "a non-null value";
|
||||
}
|
||||
|
||||
// if (String test ?= s){} // <-- compiler error: The expression type is not nullable
|
||||
s2 = s; // at this point, s is known to be a non-null String
|
||||
console.print($"{s=}, {s2=}, {s==s2=}");
|
||||
}
|
||||
}
|
||||
22
Task/Null-object/Eiffel/null-object.e
Normal file
22
Task/Null-object/Eiffel/null-object.e
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
class
|
||||
APPLICATION
|
||||
inherit
|
||||
ARGUMENTS
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
local
|
||||
i: INTEGER
|
||||
s: detachable STRING
|
||||
do
|
||||
if i = Void then
|
||||
print("i = Void")
|
||||
end
|
||||
if s = Void then
|
||||
print("s = Void")
|
||||
end
|
||||
end
|
||||
end
|
||||
4
Task/Null-object/Elixir/null-object-1.elixir
Normal file
4
Task/Null-object/Elixir/null-object-1.elixir
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
iex(1)> nil == :nil
|
||||
true
|
||||
iex(2)> is_nil(nil)
|
||||
true
|
||||
2
Task/Null-object/Elixir/null-object-2.elixir
Normal file
2
Task/Null-object/Elixir/null-object-2.elixir
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
iex(3)> if nil, do: "not execute"
|
||||
nil
|
||||
8
Task/Null-object/F-Sharp/null-object.fs
Normal file
8
Task/Null-object/F-Sharp/null-object.fs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
let sl : string list = [null; "abc"]
|
||||
|
||||
let f s =
|
||||
match s with
|
||||
| null -> "It is null!"
|
||||
| _ -> "It's non-null: " + s
|
||||
|
||||
for s in sl do printfn "%s" (f s)
|
||||
1
Task/Null-object/Factor/null-object.factor
Normal file
1
Task/Null-object/Factor/null-object.factor
Normal file
|
|
@ -0,0 +1 @@
|
|||
: is-f? ( obj -- ? ) f = ;
|
||||
7
Task/Null-object/Fantom/null-object.fantom
Normal file
7
Task/Null-object/Fantom/null-object.fantom
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fansh> x := null
|
||||
fansh> x == null
|
||||
true
|
||||
fansh> x = 1
|
||||
1
|
||||
fansh> x == null
|
||||
false
|
||||
20
Task/Null-object/FreeBASIC/null-object.basic
Normal file
20
Task/Null-object/FreeBASIC/null-object.basic
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
|
||||
8
Task/Null-object/FutureBasic/null-object.basic
Normal file
8
Task/Null-object/FutureBasic/null-object.basic
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Object dimensioned, but not assigned
|
||||
CFStringRef object
|
||||
|
||||
if ( object == NULL )
|
||||
print "object is NULL"
|
||||
end if
|
||||
|
||||
HandleEvents
|
||||
21
Task/Null-object/Go/null-object.go
Normal file
21
Task/Null-object/Go/null-object.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
s []int // slice type
|
||||
p *int // pointer type
|
||||
f func() // function type
|
||||
i interface{} // interface type
|
||||
m map[int]int // map type
|
||||
c chan int // channel type
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(s == nil)
|
||||
fmt.Println(p == nil)
|
||||
fmt.Println(f == nil)
|
||||
fmt.Println(i == nil)
|
||||
fmt.Println(m == nil)
|
||||
fmt.Println(c == nil)
|
||||
}
|
||||
3
Task/Null-object/Haskell/null-object-1.hs
Normal file
3
Task/Null-object/Haskell/null-object-1.hs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
undefined -- undefined value provided by the standard library
|
||||
error "oops" -- another undefined value
|
||||
head [] -- undefined, you can't take the head of an empty list
|
||||
1
Task/Null-object/Haskell/null-object-2.hs
Normal file
1
Task/Null-object/Haskell/null-object-2.hs
Normal file
|
|
@ -0,0 +1 @@
|
|||
data Maybe a = Nothing | Just a
|
||||
3
Task/Null-object/Haskell/null-object-3.hs
Normal file
3
Task/Null-object/Haskell/null-object-3.hs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
case thing of
|
||||
Nothing -> "It's Nothing. Or null, whatever."
|
||||
Just v -> "It's not Nothing; it is " ++ show v ++ "."
|
||||
4
Task/Null-object/Haskell/null-object-4.hs
Normal file
4
Task/Null-object/Haskell/null-object-4.hs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
add_two_maybe_numbers x y do
|
||||
a <- x
|
||||
b <- y
|
||||
return (a+b)
|
||||
4
Task/Null-object/Haskell/null-object-5.hs
Normal file
4
Task/Null-object/Haskell/null-object-5.hs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
*Main> add_two_maybe_numbers (Just 2) (Just 3)
|
||||
Just 5
|
||||
*Main> add_two_maybe_numbers (Just 2) Nothing
|
||||
Nothing
|
||||
10
Task/Null-object/Icon/null-object.icon
Normal file
10
Task/Null-object/Icon/null-object.icon
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
procedure main()
|
||||
nulltest("a",a) # unassigned variables are null by default
|
||||
nulltest("b",b := &null) # explicit assignment is possible
|
||||
nulltest("c",c := "anything")
|
||||
nulltest("c",c := &null) # varibables can't be undefined
|
||||
end
|
||||
|
||||
procedure nulltest(name,var)
|
||||
return write(name, if /var then " is" else " is not"," null.")
|
||||
end
|
||||
1
Task/Null-object/Io/null-object.io
Normal file
1
Task/Null-object/Io/null-object.io
Normal file
|
|
@ -0,0 +1 @@
|
|||
if(object == nil, "object is nil" println)
|
||||
1
Task/Null-object/J/null-object-1.j
Normal file
1
Task/Null-object/J/null-object-1.j
Normal file
|
|
@ -0,0 +1 @@
|
|||
isUndefined=: _1 = nc@boxxopen
|
||||
5
Task/Null-object/J/null-object-2.j
Normal file
5
Task/Null-object/J/null-object-2.j
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
isUndefined 'foo'
|
||||
1
|
||||
foo=:9
|
||||
isUndefined 'foo'
|
||||
0
|
||||
12
Task/Null-object/J/null-object-3.j
Normal file
12
Task/Null-object/J/null-object-3.j
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
1 1 0 1#3 4 _ 5 NB. use bitmask to select numbers
|
||||
3 4 5
|
||||
I.1 1 0 1 NB. get indices for bitmask
|
||||
0 1 3
|
||||
0 1 3 { 3 4 _ 5 NB. use indices to select numbers
|
||||
3 4 5
|
||||
1 1 0 1 #inv 3 4 5 NB. use bitmask to restore original positions
|
||||
3 4 0 5
|
||||
1 1 0 1 #!._ inv 3 4 5 NB. specify different fill element
|
||||
3 4 _ 5
|
||||
3 4 5 (0 1 3}) _ _ _ _ NB. use indices to restore original positions
|
||||
3 4 _ 5
|
||||
4
Task/Null-object/Java/null-object.java
Normal file
4
Task/Null-object/Java/null-object.java
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
// here "object" is a reference
|
||||
if (object == null) {
|
||||
System.out.println("object is null");
|
||||
}
|
||||
6
Task/Null-object/JavaScript/null-object.js
Normal file
6
Task/Null-object/JavaScript/null-object.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
if (object === null) {
|
||||
alert("object is null");
|
||||
// The object is nothing
|
||||
}
|
||||
|
||||
typeof null === "object"; // This stands since the beginning of JavaScript
|
||||
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" # => # Ничего
|
||||
7
Task/Null-object/Jsish/null-object.jsish
Normal file
7
Task/Null-object/Jsish/null-object.jsish
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* null non value */
|
||||
|
||||
if (thing == null) { puts("thing tests as null"); }
|
||||
if (thing === undefined) { puts("thing strictly tests as undefined"); }
|
||||
puts(typeof thing);
|
||||
puts(typeof null);
|
||||
puts(typeof undefined);
|
||||
6
Task/Null-object/K/null-object.k
Normal file
6
Task/Null-object/K/null-object.k
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(1;;2) ~ (1 ; _n ; 2) / ~ is ''identical to'' or ''match'' .
|
||||
1
|
||||
_n ~' ( 1 ; ; 2 ) / ''match each''
|
||||
0 1 0
|
||||
|
||||
additional properties : _n@i and _n?i are i; _n`v is _n
|
||||
2
Task/Null-object/Klingphix/null-object.klingphix
Normal file
2
Task/Null-object/Klingphix/null-object.klingphix
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
%t nan !t
|
||||
$t nan == ?
|
||||
9
Task/Null-object/Kotlin/null-object.kotlin
Normal file
9
Task/Null-object/Kotlin/null-object.kotlin
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// version 1.1.0
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val i: Int = 3 // non-nullable Int type - can't be assigned null
|
||||
println(i)
|
||||
val j: Int? = null // nullable Int type - can be assigned null
|
||||
println(j)
|
||||
println(null is Nothing?) // test that null is indeed of type Nothing?
|
||||
}
|
||||
9
Task/Null-object/Langur/null-object.langur
Normal file
9
Task/Null-object/Langur/null-object.langur
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
val .x, .y = true, null
|
||||
|
||||
writeln .x == null
|
||||
writeln .y == null
|
||||
writeln .x ==? null
|
||||
writeln .y ==? null
|
||||
|
||||
# null not a "truthy" result
|
||||
writeln if(null: 0; 1)
|
||||
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
|
||||
6
Task/Null-object/Latitude/null-object-1.latitude
Normal file
6
Task/Null-object/Latitude/null-object-1.latitude
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
foo := Nil.
|
||||
if { foo nil?. } then {
|
||||
putln: "Foo is nil".
|
||||
} else {
|
||||
putln: "Foo is not nil".
|
||||
}.
|
||||
1
Task/Null-object/Latitude/null-object-2.latitude
Normal file
1
Task/Null-object/Latitude/null-object-2.latitude
Normal file
|
|
@ -0,0 +1 @@
|
|||
Nil to (Array). ;; []
|
||||
2
Task/Null-object/Latitude/null-object-3.latitude
Normal file
2
Task/Null-object/Latitude/null-object-3.latitude
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
func := {}.
|
||||
func. ;; Nil
|
||||
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
|
||||
6
Task/Null-object/Logo/null-object.logo
Normal file
6
Task/Null-object/Logo/null-object.logo
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
to test :thing
|
||||
if empty? :thing [print [list or word is empty]]
|
||||
end
|
||||
|
||||
print empty? [] ; true
|
||||
print empty? "|| ; true
|
||||
2
Task/Null-object/Lua/null-object.lua
Normal file
2
Task/Null-object/Lua/null-object.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
isnil = (object == nil)
|
||||
print(isnil)
|
||||
12
Task/Null-object/M2000-Interpreter/null-object-1.m2000
Normal file
12
Task/Null-object/M2000-Interpreter/null-object-1.m2000
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
Module CheckWord {
|
||||
Declare Alfa "WORD.APPLICATION"
|
||||
Declare Alfa Nothing
|
||||
Print Type$(Alfa)="Nothing"
|
||||
Try ok {
|
||||
Declare Alfa "WORD.APPLICATION"
|
||||
\\ we can't declare again Alfa
|
||||
|
||||
}
|
||||
If Not Ok Then Print Error$ ' return Bad Object declaration
|
||||
}
|
||||
CheckWord
|
||||
54
Task/Null-object/M2000-Interpreter/null-object-2.m2000
Normal file
54
Task/Null-object/M2000-Interpreter/null-object-2.m2000
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
Module CheckContainers {
|
||||
\\ Arrays (A() and B() are value types)
|
||||
Dim A(10)=1, B()
|
||||
\\ B() get a copy of A(), is not a reference type
|
||||
B()=A()
|
||||
\\ we make a pointer to Array
|
||||
B=A()
|
||||
\\ now B is a reference type object
|
||||
Print Len(B)=10 ' ten items
|
||||
B+=10
|
||||
Print A(3)=11, A(7)=11
|
||||
\\ we can change pointer using a pointer to an empty array
|
||||
B=(,)
|
||||
\\ we can erase A() and B()
|
||||
Dim A(0), B(0)
|
||||
Print Len(A())=0, Len(B())=0
|
||||
Print Len(B)=0
|
||||
B=(123,)
|
||||
\\ B() is a value type so get a copy
|
||||
B()=B
|
||||
Print Len(B)=1, B(0)=123
|
||||
\\ Using Clear we pass a new empty array
|
||||
Clear B
|
||||
Print Type$(B)="mArray"
|
||||
Print Len(B)=1, B(0)=123
|
||||
|
||||
|
||||
\\ Inventrories. Keys must be unique (for normal inventories)
|
||||
Inventory M=1,2,3,4:=400,5
|
||||
Print M
|
||||
Clear M
|
||||
Inventory M=1,2,3,4,5
|
||||
Print M
|
||||
|
||||
\\ Inventory Queue can have same keys.
|
||||
Inventory Queue N=1,1,2:="old",2:="ok",3
|
||||
If Exist(N,2) Then Print Eval$(N)="ok", Eval(N!)=3 ' 4th item
|
||||
Clear N
|
||||
Print Len(N)=0, Type$(N)="Inventory"
|
||||
|
||||
\\ Stack Object
|
||||
Z=Stack:=1,2,3
|
||||
Stack Z {
|
||||
While not empty {Print Number}
|
||||
}
|
||||
Print Len(Z)=0
|
||||
Z=Stack((Stack:=1,2,3,4),Stack:=20,30,40 )
|
||||
Print Len(Z)=7
|
||||
Print Z ' 1 2 3 4 20 30 49
|
||||
Z=Stack ' This is an empty stacl
|
||||
Print Len(Z)=0
|
||||
Print Type$(Z)="mStiva"
|
||||
}
|
||||
CheckContainers
|
||||
29
Task/Null-object/M2000-Interpreter/null-object-3.m2000
Normal file
29
Task/Null-object/M2000-Interpreter/null-object-3.m2000
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
class something {
|
||||
}
|
||||
class alfa as something {
|
||||
x=10, y=20
|
||||
}
|
||||
a->alfa()
|
||||
Print a is type alfa = true
|
||||
Print a is type something = true
|
||||
a->0&
|
||||
Print a is type null = true
|
||||
\\ beta is a named object, is static
|
||||
group beta {
|
||||
type: something, alfa
|
||||
x=10, y=20
|
||||
}
|
||||
Print beta is type alfa = true
|
||||
Print beta is type something = true
|
||||
\\ now a is a pointer as a weak reference to beta
|
||||
a->beta
|
||||
print a is type alfa = true
|
||||
print a is type something = true
|
||||
a=pointer() ' same as a->0&
|
||||
Print a is type null = true
|
||||
\\ now a is a pointer of a copy of beta
|
||||
a->(beta)
|
||||
print a is type alfa = true
|
||||
print a is type something = true
|
||||
a=pointer() ' same as a->0&
|
||||
Print a is type null = true
|
||||
8
Task/Null-object/MATLAB/null-object.m
Normal file
8
Task/Null-object/MATLAB/null-object.m
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
a = []; b='';
|
||||
isempty(a)
|
||||
isempty(b)
|
||||
if (a)
|
||||
1,
|
||||
else,
|
||||
0
|
||||
end;
|
||||
1
Task/Null-object/MAXScript/null-object.max
Normal file
1
Task/Null-object/MAXScript/null-object.max
Normal file
|
|
@ -0,0 +1 @@
|
|||
if obj == undefined then print "Obj is undefined"
|
||||
18
Task/Null-object/MUMPS/null-object.mumps
Normal file
18
Task/Null-object/MUMPS/null-object.mumps
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
CACHE>WRITE $DATA(VARI)
|
||||
0
|
||||
CACHE>SET VARI="HELLO" WRITE $DATA(VARI)
|
||||
1
|
||||
CACHE>NEW VARI WRITE $DATA(VARI) ;Change to a new scope
|
||||
0
|
||||
CACHE 1S1>SET VARI(1,2)="DOWN" WRITE $DATA(VARI)
|
||||
10
|
||||
CACHE 1S1>WRITE $DATA(VARI(1))
|
||||
10
|
||||
CACHE 1S1>WRITE $D(VARI(1,2))
|
||||
1
|
||||
CACHE 1S1>SET VARI(1)="UP" WRITE $DATA(VARI(1))
|
||||
11
|
||||
<CACHE 1S1>QUIT ;Leave the scope
|
||||
|
||||
<CACHE>W $DATA(VARI)," ",VARI
|
||||
1 HELLO
|
||||
7
Task/Null-object/Maple/null-object-1.maple
Normal file
7
Task/Null-object/Maple/null-object-1.maple
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
a := NULL;
|
||||
a :=
|
||||
is (NULL = ());
|
||||
true
|
||||
if a = NULL then
|
||||
print (NULL);
|
||||
end if;
|
||||
12
Task/Null-object/Maple/null-object-2.maple
Normal file
12
Task/Null-object/Maple/null-object-2.maple
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
b := Array([1, 2, 3, Integer(undefined), 5]);
|
||||
b := [ 1 2 3 undefined 5 ]
|
||||
numelems(b);
|
||||
5
|
||||
b := Array([1, 2, 3, Float(undefined), 5]);
|
||||
b := [ 1 2 3 Float(undefined) 5 ]
|
||||
numelems(b);
|
||||
5
|
||||
b := Array([1, 2, 3, NULL, 5]);
|
||||
b := [ 1 2 3 5 ]
|
||||
numelems(b);
|
||||
4
|
||||
1
Task/Null-object/Mathematica/null-object-1.math
Normal file
1
Task/Null-object/Mathematica/null-object-1.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
x=Null;
|
||||
3
Task/Null-object/Mathematica/null-object-2.math
Normal file
3
Task/Null-object/Mathematica/null-object-2.math
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
x =.
|
||||
x = (1 + 2;)
|
||||
FullForm[x]
|
||||
1
Task/Null-object/Mathematica/null-object-3.math
Normal file
1
Task/Null-object/Mathematica/null-object-3.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
SameQ[x,Null]
|
||||
1
Task/Null-object/Mathematica/null-object-4.math
Normal file
1
Task/Null-object/Mathematica/null-object-4.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
x===Null
|
||||
4
Task/Null-object/Mathematica/null-object-5.math
Normal file
4
Task/Null-object/Mathematica/null-object-5.math
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
x =.;
|
||||
ValueQ[x]
|
||||
x = 3;
|
||||
ValueQ[x]
|
||||
2
Task/Null-object/Mathematica/null-object-6.math
Normal file
2
Task/Null-object/Mathematica/null-object-6.math
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
False
|
||||
True
|
||||
1
Task/Null-object/Min/null-object.min
Normal file
1
Task/Null-object/Min/null-object.min
Normal file
|
|
@ -0,0 +1 @@
|
|||
null null? puts!
|
||||
1
Task/Null-object/Modula-3/null-object-1.mod3
Normal file
1
Task/Null-object/Modula-3/null-object-1.mod3
Normal file
|
|
@ -0,0 +1 @@
|
|||
VAR foo := NIL
|
||||
1
Task/Null-object/Modula-3/null-object-2.mod3
Normal file
1
Task/Null-object/Modula-3/null-object-2.mod3
Normal file
|
|
@ -0,0 +1 @@
|
|||
VAR foo: REF INTEGER := NIL;
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue