Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,15 +0,0 @@
-- Ada has bitwise operators in package Interfaces,
-- but they work with Interfaces.Unsigned_*** types only.
-- Use rem or mod for Integer types, and let the compiler
-- optimize it.
declare
N : Integer := 5;
begin
if N rem 2 = 0 then
Put_Line ("Even number");
elseif N rem 2 /= 0 then
Put_Line ("Odd number");
else
Put_Line ("Something went really wrong!");
end if;
end;

View file

@ -1,4 +1,4 @@
loop (neg 5)..5 [x][
if? even? x -> print [pad to :string x 4 ": even"]
else -> print [pad to :string x 4 ": odd"]
switch even? x -> print [pad to :string x 4 ": even"]
-> print [pad to :string x 4 ": odd"]
]

View file

@ -1,14 +1,12 @@
@echo off
setlocal
set /p i=Insert number:
::bitwise and
set /a "test1=%i%&1"
::divide last character by 2
set /a test2=%i:~-1%/2
::modulo
set /a test3=%i% %% 2
set /a test2=%i% %% 2
set test
pause>nul

View file

@ -1,5 +0,0 @@
IF FUNCTION REM(Num, 2) = 0
DISPLAY Num " is even."
ELSE
DISPLAY Num " is odd."
END-IF

View file

@ -19,6 +19,13 @@
def isOdd_bAnd(n)
(n & 1) != 0
end
# Using integer predicates
def isEven_even(n)
n.even?
end
def isOdd_odd(n)
n.odd?
end
puts isEven_bShift(7)
puts isOdd_bShift(7)
@ -28,3 +35,6 @@ puts isOdd_mod(12)
puts isEven_bAnd(21)
puts isOdd_bAnd(21)
puts isEven_even(32)
puts isOdd_odd(32)

View file

@ -1,10 +0,0 @@
(require 'cl-lib)
(defun even-or-odd-p (n)
(if (cl-evenp n) 'even 'odd))
(defun even-or-odd-p (n)
(if (zerop (% n 2)) 'even 'odd))
(message "%d is %s" 3 (even-or-oddp 3))
(message "%d is %s" 2 (even-or-oddp 2))

View file

@ -1,5 +0,0 @@
include std/math.e
for i = 1 to 10 do
? {i, is_even(i)}
end for

View file

@ -1,21 +0,0 @@
MODULE EvenOrOdd;
IMPORT
S := SYSTEM,
Out;
VAR
x: INTEGER;
s: SET;
BEGIN
x := 10;Out.Int(x,0);
IF ODD(x) THEN Out.String(" odd") ELSE Out.String(" even") END;
Out.Ln;
x := 11;s := S.VAL(SET,LONG(x));Out.Int(x,0);
IF 0 IN s THEN Out.String(" odd") ELSE Out.String(" even") END;
Out.Ln;
x := 12;Out.Int(x,0);
IF x MOD 2 # 0 THEN Out.String(" odd") ELSE Out.String(" even") END;
Out.Ln
END EvenOrOdd.

View file

@ -1,2 +0,0 @@
$IsOdd = -not ( [bigint]$N ).IsEven
$IsEven = ( [bigint]$N ).IsEven

View file

@ -1,2 +0,0 @@
$IsOdd = [boolean]( $N -band 1 )
$IsEven = [boolean]( $N -band 0 )

View file

@ -1,2 +0,0 @@
$IsOdd = $N % 2 -ne 0
$IsEven = $N % 2 -eq 0

View file

@ -1,3 +0,0 @@
let is_even = d => mod(d, 2) == 0
let is_odd = d => mod(d, 2) != 0

View file

@ -1,12 +0,0 @@
Function odd_or_even(n)
If n Mod 2 = 0 Then
odd_or_even = "Even"
Else
odd_or_even = "Odd"
End If
End Function
WScript.StdOut.Write "Please enter a number: "
n = WScript.StdIn.ReadLine
WScript.StdOut.Write n & " is " & odd_or_even(CInt(n))
WScript.StdOut.WriteLine