task_url
stringlengths
30
116
task_name
stringlengths
2
86
task_description
stringlengths
0
14.4k
language_url
stringlengths
2
53
language_name
stringlengths
1
52
code
stringlengths
0
61.9k
http://rosettacode.org/wiki/Empty_directory
Empty directory
Starting with a path to some directory, determine whether the directory is empty. An empty directory contains no files nor subdirectories. With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other...
#Groovy
Groovy
def isDirEmpty = { dirName -> def dir = new File(dirName) dir.exists() && dir.directory && (dir.list() as List).empty }
http://rosettacode.org/wiki/Empty_program
Empty program
Task Create the simplest possible program that is still considered "correct."
#ArnoldC
ArnoldC
IT'S SHOWTIME YOU HAVE BEEN TERMINATED
http://rosettacode.org/wiki/Empty_program
Empty program
Task Create the simplest possible program that is still considered "correct."
#Arturo
Arturo
 
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#Ring
Ring
  # Project : Enforced immutability   x = 10 assert( x = 10) assert( x = 100 )  
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#Ruby
Ruby
msg = "Hello World" msg << "!" puts msg #=> Hello World!   puts msg.frozen? #=> false msg.freeze puts msg.frozen? #=> true begin msg << "!" rescue => e p e #=> #<RuntimeError: can't modify frozen String> end   puts msg #=> Hello World! msg2 = msg   # The...
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#Rust
Rust
let x = 3; x += 2;
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#Scala
Scala
val pi = 3.14159 val msg = "Hello World"
http://rosettacode.org/wiki/Entropy
Entropy
Task Calculate the Shannon entropy   H   of a given input string. Given the discrete random variable X {\displaystyle X} that is a string of N {\displaystyle N} "symbols" (total characters) consisting of n {\displaystyle n} different characters (n=2 for binary), the Shannon entropy of X in bit...
#Crystal
Crystal
# Method to calculate sum of Float64 array def sum(array : Array(Float64)) res = 0 array.each do |n| res += n end res end   # Method to calculate which char appears how often def histogram(source : String) hist = {} of Char => Int32 l = 0 source.each_char do |e| if !hist.has_key? e hist[e] =...
http://rosettacode.org/wiki/Ethiopian_multiplication
Ethiopian multiplication
Ethiopian multiplication is a method of multiplying integers using only addition, doubling, and halving. Method: Take two numbers to be multiplied and write them down at the top of two columns. In the left-hand column repeatedly halve the last number, discarding any remainders, and write the result below the last ...
#CoffeeScript
CoffeeScript
  halve = (n) -> Math.floor n / 2 double = (n) -> n * 2 is_even = (n) -> n % 2 == 0   multiply = (a, b) -> prod = 0 while a > 0 prod += b if !is_even a a = halve a b = double b prod   # tests do -> for i in [0..100] for j in [0..100] throw Error("broken for #{i} * #{j}") if multiply(i,j) !...
http://rosettacode.org/wiki/Equilibrium_index
Equilibrium index
An equilibrium index of a sequence is an index into the sequence such that the sum of elements at lower indices is equal to the sum of elements at higher indices. For example, in a sequence   A {\displaystyle A} :   A 0 = − 7 {\displaystyle A_{0}=-7}   A 1 = 1 {\displaystyle A_{1}=1} ...
#jq
jq
# The index origin is 0 in jq. def equilibrium_indices: def indices(a; mx): def report: # [i, headsum, tailsum] .[0] as $i | if $i == mx then empty # all done else .[1] as $h | (.[2] - a[$i]) as $t | (if $h == $t then $i else empty end), ( [ $i + 1, $h + a[$...
http://rosettacode.org/wiki/Equilibrium_index
Equilibrium index
An equilibrium index of a sequence is an index into the sequence such that the sum of elements at lower indices is equal to the sum of elements at higher indices. For example, in a sequence   A {\displaystyle A} :   A 0 = − 7 {\displaystyle A_{0}=-7}   A 1 = 1 {\displaystyle A_{1}=1} ...
#Julia
Julia
function equindex2pass(data::Array) rst = Vector{Int}(0) suml, sumr, ddelayed = 0, sum(data), 0 for (i, d) in enumerate(data) suml += ddelayed sumr -= d ddelayed = d if suml == sumr push!(rst, i) end end return rst end   @show equindex2pass([1, -1,...
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#OCaml
OCaml
Sys.getenv "HOME"
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#Oforth
Oforth
System getEnv("PATH") println
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#Oz
Oz
{System.showInfo "This is where Mozart is installed: "#{OS.getEnv 'OZHOME'}}
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#PARI.2FGP
PARI/GP
getenv("HOME")
http://rosettacode.org/wiki/Euler%27s_sum_of_powers_conjecture
Euler's sum of powers conjecture
There is a conjecture in mathematics that held for over two hundred years before it was disproved by the finding of a counterexample in 1966 by Lander and Parkin. Euler's (disproved) sum of powers   conjecture At least k positive kth powers are required to sum to a kth power, except for the trivial case...
#Haskell
Haskell
import Data.List import Data.List.Ordered   main :: IO () main = print $ head [(x0,x1,x2,x3,x4) | -- choose x0, x1, x2, x3 -- so that 250 < x3 < x2 < x1 < x0 x3 <- [1..250-1], ...
http://rosettacode.org/wiki/Factorial
Factorial
Definitions   The factorial of   0   (zero)   is defined as being   1   (unity).   The   Factorial Function   of a positive integer,   n,   is defined as the product of the sequence: n,   n-1,   n-2,   ...   1 Task Write a function to return the factorial of a number. Solutions can be iterat...
#Oberon
Oberon
  MODULE Factorial; IMPORT Out;   VAR i: INTEGER;   PROCEDURE Iterative(n: LONGINT): LONGINT; VAR i, r: LONGINT; BEGIN ASSERT(n >= 0); r := 1; FOR i := n TO 2 BY -1 DO r := r * i END; RETURN r END Iterative;   PROCEDURE Recursive(n: LONGINT): LONGINT; VAR r: LONGINT; ...
http://rosettacode.org/wiki/Even_or_odd
Even or odd
Task Test whether an integer is even or odd. There is more than one way to solve this task: Use the even and odd predicates, if the language provides them. Check the least significant digit. With binary integers, i bitwise-and 1 equals 0 iff i is even, or equals 1 iff i is odd. Divide i by 2. The remainder equals...
#Component_Pascal
Component Pascal
  MODULE EvenOdd; IMPORT StdLog,Args,Strings;   PROCEDURE BitwiseOdd(i: INTEGER): BOOLEAN; BEGIN RETURN 0 IN BITS(i) END BitwiseOdd;   PROCEDURE Odd(i: INTEGER): BOOLEAN; BEGIN RETURN (i MOD 2) # 0 END Odd;   PROCEDURE CongruenceOdd(i: INTEGER): BOOLEAN; BEGIN RETURN ((i -1) MOD 2) = 0 END CongruenceOdd;   PROCEDURE...
http://rosettacode.org/wiki/Euler_method
Euler method
Euler's method numerically approximates solutions of first-order ordinary differential equations (ODEs) with a given initial value.   It is an explicit method for solving initial value problems (IVPs), as described in the wikipedia page. The ODE has to be provided in the following form: d y ( t ) d t = f...
#Smalltalk
Smalltalk
ODESolver>>eulerOf: f init: y0 from: a to: b step: h | t y | t := a. y := y0. [ t < b ] whileTrue: [ Transcript show: t asString, ' ' , (y printShowingDecimalPlaces: 3); cr. t := t + h. y := y + (h * (f value: t value: y)) ]   ODESolver new eulerOf: [:time :temp| -0.07 * (temp - 20)] init: 100 ...
http://rosettacode.org/wiki/Evaluate_binomial_coefficients
Evaluate binomial coefficients
This programming task, is to calculate ANY binomial coefficient. However, it has to be able to output   ( 5 3 ) {\displaystyle {\binom {5}{3}}} ,   which is   10. This formula is recommended: ( n k ) = n ! ( n − k ) ! k ! = n ( n − 1 ) ( n − 2 ) … ( n − k + 1 ) k ( k − 1...
#Lasso
Lasso
define binomial(n::integer,k::integer) => { #k == 0 ? return 1 local(result = 1) loop(#k) => { #result = #result * (#n - loop_count + 1) / loop_count } return #result } // Tests binomial(5, 3) binomial(5, 4) binomial(60, 30)
http://rosettacode.org/wiki/Evaluate_binomial_coefficients
Evaluate binomial coefficients
This programming task, is to calculate ANY binomial coefficient. However, it has to be able to output   ( 5 3 ) {\displaystyle {\binom {5}{3}}} ,   which is   10. This formula is recommended: ( n k ) = n ! ( n − k ) ! k ! = n ( n − 1 ) ( n − 2 ) … ( n − k + 1 ) k ( k − 1...
#Liberty_BASIC
Liberty BASIC
  ' [RC] Binomial Coefficients   print "Binomial Coefficient of "; 5; " and "; 3; " is ",BinomialCoefficient( 5, 3) n =1 +int( 10 *rnd( 1)) k =1 +int( n *rnd( 1)) print "Binomial Coefficient of "; n; " and "; k; " is ",BinomialCoefficient( n, k)   end   function BinomialCoefficient( n, k) ...
http://rosettacode.org/wiki/Emirp_primes
Emirp primes
An   emirp   (prime spelled backwards)   are primes that when reversed   (in their decimal representation)   are a different prime. (This rules out palindromic primes.) Task   show the first   twenty   emirps   show all emirps between   7,700   and   8,000   show the   10,000th   emirp In each list, the numbe...
#C.2B.2B
C++
#include <vector> #include <iostream> #include <algorithm> #include <sstream> #include <string> #include <cmath>   bool isPrime ( int number ) { if ( number <= 1 ) return false ; if ( number == 2 ) return true ; for ( int i = 2 ; i <= std::sqrt( number ) ; i++ ) { if ( number % i == 0 ) re...
http://rosettacode.org/wiki/Elliptic_curve_arithmetic
Elliptic curve arithmetic
Elliptic curves   are sometimes used in   cryptography   as a way to perform   digital signatures. The purpose of this task is to implement a simplified (without modular arithmetic) version of the elliptic curve arithmetic which is required by the   elliptic curve DSA   protocol. In a nutshell, an elliptic curve is a...
#PARI.2FGP
PARI/GP
e=ellinit([0,7]); a=[-6^(1/3),1] b=[-3^(1/3),2] c=elladd(e,a,b) d=ellneg(e,c) elladd(e,c,d) elladd(e,elladd(e,a,b),d) ellmul(e,a,12345)
http://rosettacode.org/wiki/Elliptic_curve_arithmetic
Elliptic curve arithmetic
Elliptic curves   are sometimes used in   cryptography   as a way to perform   digital signatures. The purpose of this task is to implement a simplified (without modular arithmetic) version of the elliptic curve arithmetic which is required by the   elliptic curve DSA   protocol. In a nutshell, an elliptic curve is a...
#Perl
Perl
package EC; { our ($A, $B) = (0, 7); package EC::Point; sub new { my $class = shift; bless [ @_ ], $class } sub zero { bless [], shift } sub x { shift->[0] }; sub y { shift->[1] }; sub double { my $self = shift; return $self unless @$self; my $L = (3 * $self->x**2) / (2*$...
http://rosettacode.org/wiki/Enumerations
Enumerations
Task Create an enumeration of constants with and without explicit values.
#Metafont
Metafont
vardef enum(expr first)(text t) = save ?; ? := first; forsuffixes e := t: e := ?; ?:=?+1; endfor enddef;
http://rosettacode.org/wiki/Enumerations
Enumerations
Task Create an enumeration of constants with and without explicit values.
#Modula-3
Modula-3
TYPE Fruit = {Apple, Banana, Cherry};
http://rosettacode.org/wiki/Enumerations
Enumerations
Task Create an enumeration of constants with and without explicit values.
#Nemerle
Nemerle
enum Fruit { |apple |banana |cherry }   enum Season { |winter = 1 |spring = 2 |summer = 3 |autumn = 4 }
http://rosettacode.org/wiki/Elementary_cellular_automaton/Random_Number_Generator
Elementary cellular automaton/Random Number Generator
Rule 30 is considered to be chaotic enough to generate good pseudo-random numbers. As a matter of fact, rule 30 is used by the Mathematica software for its default random number generator. Steven Wolfram's recommendation for random number generation from rule 30 consists in extracting successive bits in a fixed positi...
#Ruby
Ruby
size = 100 eca = ElemCellAutomat.new("1"+"0"*(size-1), 30) eca.take(80).map{|line| line[0]}.each_slice(8){|bin| p bin.join.to_i(2)}
http://rosettacode.org/wiki/Elementary_cellular_automaton/Random_Number_Generator
Elementary cellular automaton/Random Number Generator
Rule 30 is considered to be chaotic enough to generate good pseudo-random numbers. As a matter of fact, rule 30 is used by the Mathematica software for its default random number generator. Steven Wolfram's recommendation for random number generation from rule 30 consists in extracting successive bits in a fixed positi...
#Rust
Rust
  //Assuming the code from the Elementary cellular automaton task is in the namespace. fn main() { struct WolfGen(ElementaryCA); impl WolfGen { fn new() -> WolfGen { let (_, ca) = ElementaryCA::new(30); WolfGen(ca) } fn next(&mut self) -> u8 { let mut ...
http://rosettacode.org/wiki/Elementary_cellular_automaton/Random_Number_Generator
Elementary cellular automaton/Random Number Generator
Rule 30 is considered to be chaotic enough to generate good pseudo-random numbers. As a matter of fact, rule 30 is used by the Mathematica software for its default random number generator. Steven Wolfram's recommendation for random number generation from rule 30 consists in extracting successive bits in a fixed positi...
#Scheme
Scheme
  ; uses SRFI-1 library http://srfi.schemers.org/srfi-1/srfi-1.html   (define (random-r30 n) (let ((r30 (vector 0 1 1 1 1 0 0 0))) (fold (lambda (x y ls) (if (= x 1) (cons (* x y) ls) (cons (+ (car ls) (* x y)) (cdr ls)))) '() (circular-list 1 2 4 8 16 32 64 128) (unfold-right (lam...
http://rosettacode.org/wiki/Empty_string
Empty string
Languages may have features for dealing specifically with empty strings (those containing no characters). Task   Demonstrate how to assign an empty string to a variable.   Demonstrate how to check that a string is empty.   Demonstrate how to check that a string is not empty. Other tasks related to string oper...
#BASIC
BASIC
10 LET A$="" 20 IF A$="" THEN PRINT "THE STRING IS EMPTY" 30 IF A$<>"" THEN PRINT "THE STRING IS NOT EMPTY" 40 END
http://rosettacode.org/wiki/Empty_string
Empty string
Languages may have features for dealing specifically with empty strings (those containing no characters). Task   Demonstrate how to assign an empty string to a variable.   Demonstrate how to check that a string is empty.   Demonstrate how to check that a string is not empty. Other tasks related to string oper...
#Batch_File
Batch File
  @echo off ::set "var" as a blank string. set var= ::check if "var" is a blank string. if not defined var echo Var is a blank string. ::Alternatively, if %var%@ equ @ echo Var is a blank string. ::check if "var" is not a blank string. if defined var echo Var is defined. ::Alternatively, if %var%@ neq @ echo Var is ...
http://rosettacode.org/wiki/Empty_directory
Empty directory
Starting with a path to some directory, determine whether the directory is empty. An empty directory contains no files nor subdirectories. With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other...
#Haskell
Haskell
import System.Directory (getDirectoryContents) import System.Environment (getArgs)     isEmpty x = getDirectoryContents x >>= return . f . (== [".", ".."]) where f True = "Directory is empty" f False = "Directory is not empty"   main = getArgs >>= isEmpty . (!! 0) >>= putStrLn
http://rosettacode.org/wiki/Empty_directory
Empty directory
Starting with a path to some directory, determine whether the directory is empty. An empty directory contains no files nor subdirectories. With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other...
#Icon_and_Unicon
Icon and Unicon
procedure main() every dir := "." | "./empty" do write(dir, if isdirempty(dir) then " is empty" else " is not empty") end   procedure isdirempty(s) #: succeeds if directory s is empty (and a directory) local d,f if ( stat(s).mode ? ="d" ) & ( d := open(s) ) then { while f := read(d) do ...
http://rosettacode.org/wiki/Empty_program
Empty program
Task Create the simplest possible program that is still considered "correct."
#Asymptote
Asymptote
 
http://rosettacode.org/wiki/Empty_program
Empty program
Task Create the simplest possible program that is still considered "correct."
#AutoHotkey
AutoHotkey
#Persistent
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#Scheme
Scheme
(define-syntax define-constant (syntax-rules () ((_ id v) (begin (define _id v) (define-syntax id (make-variable-transformer (lambda (stx) (syntax-case stx (set!) ((set! id _) (raise (syntax-violation '...
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#Seed7
Seed7
const integer: foo is 42; const string: bar is "bar"; const blahtype: blah is blahvalue;
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#Sidef
Sidef
define PI = 3.14159; # compile-time defined constant const MSG = "Hello world!"; # run-time defined constant
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#SuperCollider
SuperCollider
// you can freeze any object. b = [1, 2, 3]; b[1] = 100; // returns [1, 100, 3] b.freeze; // make b immutable b[1] = 2; // throws an error ("Attempted write to immutable object.")
http://rosettacode.org/wiki/Entropy
Entropy
Task Calculate the Shannon entropy   H   of a given input string. Given the discrete random variable X {\displaystyle X} that is a string of N {\displaystyle N} "symbols" (total characters) consisting of n {\displaystyle n} different characters (n=2 for binary), the Shannon entropy of X in bit...
#D
D
import std.stdio, std.algorithm, std.math;   double entropy(T)(T[] s) pure nothrow if (__traits(compiles, s.sort())) { immutable sLen = s.length; return s .sort() .group .map!(g => g[1] / double(sLen)) .map!(p => -p * p.log2) .sum; }   void main() { "12...
http://rosettacode.org/wiki/Ethiopian_multiplication
Ethiopian multiplication
Ethiopian multiplication is a method of multiplying integers using only addition, doubling, and halving. Method: Take two numbers to be multiplied and write them down at the top of two columns. In the left-hand column repeatedly halve the last number, discarding any remainders, and write the result below the last ...
#ColdFusion
ColdFusion
<cffunction name="double"> <cfargument name="number" type="numeric" required="true"> <cfset answer = number * 2> <cfreturn answer> </cffunction>   <cffunction name="halve"> <cfargument name="number" type="numeric" required="true"> <cfset answer = int(number / 2)> <cfreturn answer> </cffunction>   <cff...
http://rosettacode.org/wiki/Equilibrium_index
Equilibrium index
An equilibrium index of a sequence is an index into the sequence such that the sum of elements at lower indices is equal to the sum of elements at higher indices. For example, in a sequence   A {\displaystyle A} :   A 0 = − 7 {\displaystyle A_{0}=-7}   A 1 = 1 {\displaystyle A_{1}=1} ...
#K
K
f:{&{(+/y# x)=+/(y+1)_x}[x]'!#x}   f -7 1 5 2 -4 3 0 3 6   f 2 4 6 !0   f 2 9 2 ,1   f 1 -1 1 -1 1 -1 1 0 1 2 3 4 5 6
http://rosettacode.org/wiki/Equilibrium_index
Equilibrium index
An equilibrium index of a sequence is an index into the sequence such that the sum of elements at lower indices is equal to the sum of elements at higher indices. For example, in a sequence   A {\displaystyle A} :   A 0 = − 7 {\displaystyle A_{0}=-7}   A 1 = 1 {\displaystyle A_{1}=1} ...
#Kotlin
Kotlin
// version 1.1   fun equilibriumIndices(a: IntArray): MutableList<Int> { val ei = mutableListOf<Int>() if (a.isEmpty()) return ei // empty list val sumAll = a.sumBy { it } var sumLeft = 0 var sumRight: Int for (i in 0 until a.size) { sumRight = sumAll - sumLeft - a[i] if (sumLeft == sum...
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#Perl
Perl
print $ENV{HOME}, "\n";
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#Phix
Phix
without js -- none such in a browser, that I know of ?getenv("PATH")
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#PHP
PHP
$_ENV['HOME']
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#PicoLisp
PicoLisp
: (sys "TERM") -> "xterm"   : (sys "SHELL") -> "/bin/bash"
http://rosettacode.org/wiki/Euler%27s_sum_of_powers_conjecture
Euler's sum of powers conjecture
There is a conjecture in mathematics that held for over two hundred years before it was disproved by the finding of a counterexample in 1966 by Lander and Parkin. Euler's (disproved) sum of powers   conjecture At least k positive kth powers are required to sum to a kth power, except for the trivial case...
#J
J
require 'stats' (#~ (= <.)@((+/"1)&.:(^&5)))1+4 comb 248 27 84 110 133
http://rosettacode.org/wiki/Factorial
Factorial
Definitions   The factorial of   0   (zero)   is defined as being   1   (unity).   The   Factorial Function   of a positive integer,   n,   is defined as the product of the sequence: n,   n-1,   n-2,   ...   1 Task Write a function to return the factorial of a number. Solutions can be iterat...
#Objeck
Objeck
bundle Default { class Fact { function : Main(args : String[]) ~ Nil { 5->Factorial()->PrintLine(); } } }
http://rosettacode.org/wiki/Even_or_odd
Even or odd
Task Test whether an integer is even or odd. There is more than one way to solve this task: Use the even and odd predicates, if the language provides them. Check the least significant digit. With binary integers, i bitwise-and 1 equals 0 iff i is even, or equals 1 iff i is odd. Divide i by 2. The remainder equals...
#Crystal
Crystal
#Using bitwise shift def isEven_bShift(n) n == ((n >> 1) << 1) end def isOdd_bShift(n) n != ((n >> 1) << 1) end #Using modulo operator def isEven_mod(n) (n % 2) == 0 end def isOdd_mod(n) (n % 2) != 0 end # Using bitwise "and" def isEven_bAnd(n) (n & 1) == 0 end def isOdd_bAnd(...
http://rosettacode.org/wiki/Even_or_odd
Even or odd
Task Test whether an integer is even or odd. There is more than one way to solve this task: Use the even and odd predicates, if the language provides them. Check the least significant digit. With binary integers, i bitwise-and 1 equals 0 iff i is even, or equals 1 iff i is odd. Divide i by 2. The remainder equals...
#D
D
void main() { import std.stdio, std.bigint;   foreach (immutable i; -5 .. 6) writeln(i, " ", i & 1, " ", i % 2, " ", i.BigInt % 2); }
http://rosettacode.org/wiki/Euler_method
Euler method
Euler's method numerically approximates solutions of first-order ordinary differential equations (ODEs) with a given initial value.   It is an explicit method for solving initial value problems (IVPs), as described in the wikipedia page. The ODE has to be provided in the following form: d y ( t ) d t = f...
#Swift
Swift
import Foundation   let numberFormat = " %7.3f" let k = 0.07 let initialTemp = 100.0 let finalTemp = 20.0 let startTime = 0 let endTime = 100   func ivpEuler(function: (Double, Double) -> Double, initialValue: Double, step: Int) { print(String(format: " Step %2d: ", step), terminator: "") var y = initialValue ...
http://rosettacode.org/wiki/Euler_method
Euler method
Euler's method numerically approximates solutions of first-order ordinary differential equations (ODEs) with a given initial value.   It is an explicit method for solving initial value problems (IVPs), as described in the wikipedia page. The ODE has to be provided in the following form: d y ( t ) d t = f...
#Tcl
Tcl
proc euler {f y0 a b h} { puts "computing $f over \[$a..$b\], step $h" set y [expr {double($y0)}] for {set t [expr {double($a)}]} {$t < $b} {set t [expr {$t + $h}]} { puts [format "%.3f\t%.3f" $t $y] set y [expr {$y + $h * double([$f $t $y])}] } puts "done" }
http://rosettacode.org/wiki/Evaluate_binomial_coefficients
Evaluate binomial coefficients
This programming task, is to calculate ANY binomial coefficient. However, it has to be able to output   ( 5 3 ) {\displaystyle {\binom {5}{3}}} ,   which is   10. This formula is recommended: ( n k ) = n ! ( n − k ) ! k ! = n ( n − 1 ) ( n − 2 ) … ( n − k + 1 ) k ( k − 1...
#Logo
Logo
to choose :n :k if :k = 0 [output 1] output (choose :n :k-1) * (:n - :k + 1) / :k end   show choose 5 3  ; 10 show choose 60 30 ; 1.18264581564861e+17
http://rosettacode.org/wiki/Evaluate_binomial_coefficients
Evaluate binomial coefficients
This programming task, is to calculate ANY binomial coefficient. However, it has to be able to output   ( 5 3 ) {\displaystyle {\binom {5}{3}}} ,   which is   10. This formula is recommended: ( n k ) = n ! ( n − k ) ! k ! = n ( n − 1 ) ( n − 2 ) … ( n − k + 1 ) k ( k − 1...
#Lua
Lua
function Binomial( n, k ) if k > n then return nil end if k > n/2 then k = n - k end -- (n k) = (n n-k)   numer, denom = 1, 1 for i = 1, k do numer = numer * ( n - i + 1 ) denom = denom * i end return numer / denom end
http://rosettacode.org/wiki/Emirp_primes
Emirp primes
An   emirp   (prime spelled backwards)   are primes that when reversed   (in their decimal representation)   are a different prime. (This rules out palindromic primes.) Task   show the first   twenty   emirps   show all emirps between   7,700   and   8,000   show the   10,000th   emirp In each list, the numbe...
#Clojure
Clojure
(defn emirp? [v] (let [a (biginteger v) b (biginteger (clojure.string/reverse (str v)))] (and (not= a b) (.isProbablePrime a 16) (.isProbablePrime b 16))))   ; Generate the output (println "first20: " (clojure.string/join " " (take 20 (filter emirp? (iterate inc 0))))) (println "7700-...
http://rosettacode.org/wiki/Elliptic_curve_arithmetic
Elliptic curve arithmetic
Elliptic curves   are sometimes used in   cryptography   as a way to perform   digital signatures. The purpose of this task is to implement a simplified (without modular arithmetic) version of the elliptic curve arithmetic which is required by the   elliptic curve DSA   protocol. In a nutshell, an elliptic curve is a...
#Phix
Phix
with javascript_semantics constant X=1, Y=2, bCoeff=7, INF = 1e300*1e300 type point(object pt) return sequence(pt) and length(pt)=2 and atom(pt[X]) and atom(pt[Y]) end type function zero() point pt = {INF, INF} return pt end function function is_zero(point p) return p[X]>1e20 or p[X]<-1e20 end fun...
http://rosettacode.org/wiki/Enumerations
Enumerations
Task Create an enumeration of constants with and without explicit values.
#Nim
Nim
# Simple declaration. type Fruits1 = enum aApple, aBanana, aCherry   # Specifying values (accessible using "ord"). type Fruits2 = enum bApple = 0, bBanana = 2, bCherry = 5   # Enumerations with a scope which prevent name conflict. type Fruits3 {.pure.} = enum Apple, Banana, Cherry type Fruits4 {.pure.} = enum Apple = 3...
http://rosettacode.org/wiki/Enumerations
Enumerations
Task Create an enumeration of constants with and without explicit values.
#Objeck
Objeck
  enum Color := -3 { Red, White, Blue }   enum Dog { Pug, Boxer, Terrier }  
http://rosettacode.org/wiki/Enumerations
Enumerations
Task Create an enumeration of constants with and without explicit values.
#Objective-C
Objective-C
typedef NS_ENUM(NSInteger, fruits) { apple, banana, cherry };   typedef NS_ENUM(NSInteger, fruits) { apple = 0, banana = 1, cherry = 2 };
http://rosettacode.org/wiki/Elementary_cellular_automaton/Random_Number_Generator
Elementary cellular automaton/Random Number Generator
Rule 30 is considered to be chaotic enough to generate good pseudo-random numbers. As a matter of fact, rule 30 is used by the Mathematica software for its default random number generator. Steven Wolfram's recommendation for random number generation from rule 30 consists in extracting successive bits in a fixed positi...
#Sidef
Sidef
var auto = Automaton(30, [1] + 100.of(0));   10.times { var sum = 0; 8.times { sum = (2*sum + auto.cells[0]); auto.next; }; say sum; };
http://rosettacode.org/wiki/Elementary_cellular_automaton/Random_Number_Generator
Elementary cellular automaton/Random Number Generator
Rule 30 is considered to be chaotic enough to generate good pseudo-random numbers. As a matter of fact, rule 30 is used by the Mathematica software for its default random number generator. Steven Wolfram's recommendation for random number generation from rule 30 consists in extracting successive bits in a fixed positi...
#Tcl
Tcl
oo::class create RandomGenerator { superclass ElementaryAutomaton variable s constructor {stateLength} { next 30 set s [split 1[string repeat 0 $stateLength] ""] }   method rand {} { set bits {} while {[llength $bits] < 8} { lappend bits [lindex $s 0] set s [my evolve $s] } return [s...
http://rosettacode.org/wiki/Elementary_cellular_automaton/Random_Number_Generator
Elementary cellular automaton/Random Number Generator
Rule 30 is considered to be chaotic enough to generate good pseudo-random numbers. As a matter of fact, rule 30 is used by the Mathematica software for its default random number generator. Steven Wolfram's recommendation for random number generation from rule 30 consists in extracting successive bits in a fixed positi...
#Wren
Wren
import "/big" for BigInt   var n = 64   var pow2 = Fn.new { |x| BigInt.one << x }   var evolve = Fn.new { |state, rule| for (p in 0..9) { var b = BigInt.zero for (q in 7..0) { var st = state.copy() b = b | ((st & 1) << q) state = BigInt.zero for (i in ...
http://rosettacode.org/wiki/Empty_string
Empty string
Languages may have features for dealing specifically with empty strings (those containing no characters). Task   Demonstrate how to assign an empty string to a variable.   Demonstrate how to check that a string is empty.   Demonstrate how to check that a string is not empty. Other tasks related to string oper...
#BBC_BASIC
BBC BASIC
REM assign an empty string to a variable: var$ = ""   REM Check that a string is empty: IF var$ = "" THEN PRINT "String is empty"   REM Check that a string is not empty: IF var$ <> "" THEN PRINT "String is not empty"  
http://rosettacode.org/wiki/Empty_string
Empty string
Languages may have features for dealing specifically with empty strings (those containing no characters). Task   Demonstrate how to assign an empty string to a variable.   Demonstrate how to check that a string is empty.   Demonstrate how to check that a string is not empty. Other tasks related to string oper...
#BQN
BQN
•Show "" •Show 0 = ≠ "" •Show 0 ≠ ≠ "" •Show "" ≡ ⟨⟩
http://rosettacode.org/wiki/Empty_directory
Empty directory
Starting with a path to some directory, determine whether the directory is empty. An empty directory contains no files nor subdirectories. With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other...
#J
J
require 'dir' empty_dir=: 0 = '/*' #@dir@,~ ]
http://rosettacode.org/wiki/Empty_directory
Empty directory
Starting with a path to some directory, determine whether the directory is empty. An empty directory contains no files nor subdirectories. With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other...
#Java
Java
import java.nio.file.Paths; //... other class code here public static boolean isEmptyDir(String dirName){ return Paths.get(dirName).toFile().listFiles().length == 0; }
http://rosettacode.org/wiki/Empty_directory
Empty directory
Starting with a path to some directory, determine whether the directory is empty. An empty directory contains no files nor subdirectories. With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other...
#JavaScript
JavaScript
// Node.js v14.15.4 const { readdirSync } = require("fs"); const emptydir = (path) => readdirSync(path).length == 0;   // tests, run like node emptydir.js [directories] for (let i = 2; i < process.argv.length; i ++) { let dir = process.argv[i]; console.log(`${dir}: ${emptydir(dir) ? "" : "not "}empty`) }
http://rosettacode.org/wiki/Empty_program
Empty program
Task Create the simplest possible program that is still considered "correct."
#AutoIt
AutoIt
;nothing
http://rosettacode.org/wiki/Empty_program
Empty program
Task Create the simplest possible program that is still considered "correct."
#Avail
Avail
Module "a" Body
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#Swift
Swift
let a = 1 a = 1 // error: a is immutable var b = 1 b = 1
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#Tcl
Tcl
proc constant {varName {value ""}} { upvar 1 $varName var # Allow application of immutability to an existing variable, e.g., a procedure argument if {[llength [info frame 0]] == 2} {set value $var} else {set var $value} trace add variable var write [list apply {{val v1 v2 op} { upvar 1 $v1 var ...
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#UNIX_Shell
UNIX Shell
PIE=APPLE readonly PIE
http://rosettacode.org/wiki/Enforced_immutability
Enforced immutability
Task Demonstrate any means your language has to prevent the modification of values, or to create objects that cannot be modified after they have been created.
#XPL0
XPL0
define Pi=3.14; Pi:= 3.15; \causes a compile error: statement starting with a constant  
http://rosettacode.org/wiki/Entropy
Entropy
Task Calculate the Shannon entropy   H   of a given input string. Given the discrete random variable X {\displaystyle X} that is a string of N {\displaystyle N} "symbols" (total characters) consisting of n {\displaystyle n} different characters (n=2 for binary), the Shannon entropy of X in bit...
#Delphi
Delphi
  program Entropytest;   uses StrUtils, Math;   type FArray = array of CARDINAL;   var strng: string = '1223334444';   // list unique characters in a string function uniquechars(str: string): string; var n: CARDINAL; begin Result := ''; for n := 1 to length(str) do if (PosEx(str[n], str, n) > 0) and (...
http://rosettacode.org/wiki/Ethiopian_multiplication
Ethiopian multiplication
Ethiopian multiplication is a method of multiplying integers using only addition, doubling, and halving. Method: Take two numbers to be multiplied and write them down at the top of two columns. In the left-hand column repeatedly halve the last number, discarding any remainders, and write the result below the last ...
#Common_Lisp
Common Lisp
(defun ethiopian-multiply (l r) (flet ((halve (n) (floor n 2)) (double (n) (* n 2)) (even-p (n) (zerop (mod n 2)))) (do ((product 0 (if (even-p l) product (+ product r))) (l l (halve l)) (r r (double r))) ((zerop l) product))))
http://rosettacode.org/wiki/Equilibrium_index
Equilibrium index
An equilibrium index of a sequence is an index into the sequence such that the sum of elements at lower indices is equal to the sum of elements at higher indices. For example, in a sequence   A {\displaystyle A} :   A 0 = − 7 {\displaystyle A_{0}=-7}   A 1 = 1 {\displaystyle A_{1}=1} ...
#Liberty_BASIC
Liberty BASIC
  a(0)=-7 a(1)=1 a(2)=5 a(3)=2 a(4)=-4 a(5)=3 a(6)=0   print "EQ Indices are ";EQindex$("a",0,6)   wait   function EQindex$(b$,mini,maxi) if mini>=maxi then exit function sum=0 for i = mini to maxi sum=sum+eval(b$;"(";i;")") next sumA=0:sumB=sum for i = mini to maxi sumB = sumB -...
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#Pike
Pike
write("%s\n", getenv("SHELL"));
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#PowerShell
PowerShell
$Env:Path
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#Prolog
Prolog
 ?- getenv('TEMP', Temp).
http://rosettacode.org/wiki/Environment_variables
Environment variables
Task Show how to get one of your process's environment variables. The available variables vary by system;   some of the common ones available on Unix include:   PATH   HOME   USER
#PureBasic
PureBasic
GetEnvironmentVariable("Name")
http://rosettacode.org/wiki/Euler%27s_sum_of_powers_conjecture
Euler's sum of powers conjecture
There is a conjecture in mathematics that held for over two hundred years before it was disproved by the finding of a counterexample in 1966 by Lander and Parkin. Euler's (disproved) sum of powers   conjecture At least k positive kth powers are required to sum to a kth power, except for the trivial case...
#Java
Java
public class eulerSopConjecture {   static final int MAX_NUMBER = 250;   public static void main( String[] args ) { boolean found = false; long[] fifth = new long[ MAX_NUMBER ];   for( int i = 1; i <= MAX_NUMBER; i ++ ) { long i2 = i * i; fifth[ i...
http://rosettacode.org/wiki/Factorial
Factorial
Definitions   The factorial of   0   (zero)   is defined as being   1   (unity).   The   Factorial Function   of a positive integer,   n,   is defined as the product of the sequence: n,   n-1,   n-2,   ...   1 Task Write a function to return the factorial of a number. Solutions can be iterat...
#OCaml
OCaml
let rec factorial n = if n <= 0 then 1 else n * factorial (n-1)
http://rosettacode.org/wiki/Even_or_odd
Even or odd
Task Test whether an integer is even or odd. There is more than one way to solve this task: Use the even and odd predicates, if the language provides them. Check the least significant digit. With binary integers, i bitwise-and 1 equals 0 iff i is even, or equals 1 iff i is odd. Divide i by 2. The remainder equals...
#DCL
DCL
$! in DCL, for integers, the least significant bit determines the logical value, where 1 is true and 0 is false $ $ i = -5 $ loop1: $ if i then $ write sys$output i, " is odd" $ if .not. i then $ write sys$output i, " is even" $ i = i + 1 $ if i .le. 6 then $ goto loop1
http://rosettacode.org/wiki/Euler_method
Euler method
Euler's method numerically approximates solutions of first-order ordinary differential equations (ODEs) with a given initial value.   It is an explicit method for solving initial value problems (IVPs), as described in the wikipedia page. The ODE has to be provided in the following form: d y ( t ) d t = f...
#VBA
VBA
Private Sub ivp_euler(f As String, y As Double, step As Integer, end_t As Integer) Dim t As Integer Debug.Print " Step "; step; ": ", Do While t <= end_t If t Mod 10 = 0 Then Debug.Print Format(y, "0.000"), y = y + step * Application.Run(f, y) t = t + step Loop Debug.Print En...
http://rosettacode.org/wiki/Evaluate_binomial_coefficients
Evaluate binomial coefficients
This programming task, is to calculate ANY binomial coefficient. However, it has to be able to output   ( 5 3 ) {\displaystyle {\binom {5}{3}}} ,   which is   10. This formula is recommended: ( n k ) = n ! ( n − k ) ! k ! = n ( n − 1 ) ( n − 2 ) … ( n − k + 1 ) k ( k − 1...
#Maple
Maple
convert(binomial(n,k),factorial);   binomial(5,3);
http://rosettacode.org/wiki/Evaluate_binomial_coefficients
Evaluate binomial coefficients
This programming task, is to calculate ANY binomial coefficient. However, it has to be able to output   ( 5 3 ) {\displaystyle {\binom {5}{3}}} ,   which is   10. This formula is recommended: ( n k ) = n ! ( n − k ) ! k ! = n ( n − 1 ) ( n − 2 ) … ( n − k + 1 ) k ( k − 1...
#Mathematica_.2F_Wolfram_Language
Mathematica / Wolfram Language
(Local) In[1]:= Binomial[5,3] (Local) Out[1]= 10
http://rosettacode.org/wiki/Emirp_primes
Emirp primes
An   emirp   (prime spelled backwards)   are primes that when reversed   (in their decimal representation)   are a different prime. (This rules out palindromic primes.) Task   show the first   twenty   emirps   show all emirps between   7,700   and   8,000   show the   10,000th   emirp In each list, the numbe...
#Common_Lisp
Common Lisp
(defun primep (n) "Is N prime?" (and (> n 1) (or (= n 2) (oddp n)) (loop for i from 3 to (isqrt n) by 2 never (zerop (rem n i)))))   (defun reverse-digits (n) (labels ((next (n v) (if (zerop n) v (multiple-value-bind (q r) (truncate n 10) ...
http://rosettacode.org/wiki/Elliptic_curve_arithmetic
Elliptic curve arithmetic
Elliptic curves   are sometimes used in   cryptography   as a way to perform   digital signatures. The purpose of this task is to implement a simplified (without modular arithmetic) version of the elliptic curve arithmetic which is required by the   elliptic curve DSA   protocol. In a nutshell, an elliptic curve is a...
#PicoLisp
PicoLisp
(scl 16) (load "@lib/math.l") (setq *B 7) (de from_y (Y) (let (A (* 1.0 (- (* Y Y) *B)) B (pow (abs A) (*/ 1.0 1.0 3.0)) ) (list (if (gt0 A) B (- B)) (* Y 1.0) ) ) ) (de prn (P) (if (is_zero P) "Zero" (pack (round (car P) 3) " " (round ...
http://rosettacode.org/wiki/Elliptic_curve_arithmetic
Elliptic curve arithmetic
Elliptic curves   are sometimes used in   cryptography   as a way to perform   digital signatures. The purpose of this task is to implement a simplified (without modular arithmetic) version of the elliptic curve arithmetic which is required by the   elliptic curve DSA   protocol. In a nutshell, an elliptic curve is a...
#Python
Python
#!/usr/bin/env python3   class Point: b = 7 def __init__(self, x=float('inf'), y=float('inf')): self.x = x self.y = y   def copy(self): return Point(self.x, self.y)   def is_zero(self): return self.x > 1e20 or self.x < -1e20   def neg(self): return Point(self....
http://rosettacode.org/wiki/Enumerations
Enumerations
Task Create an enumeration of constants with and without explicit values.
#OCaml
OCaml
type fruit = | Apple | Banana | Cherry
http://rosettacode.org/wiki/Enumerations
Enumerations
Task Create an enumeration of constants with and without explicit values.
#Oforth
Oforth
[ $apple, $banana, $cherry ] const: Fruits
http://rosettacode.org/wiki/Enumerations
Enumerations
Task Create an enumeration of constants with and without explicit values.
#Ol
Ol
  (define fruits '{ apple 0 banana 1 cherry 2}) ; or (define fruits { 'apple 0 'banana 1 'cherry 2})   ; getting enumeration value: (print (get fruits 'apple -1)) ; ==> 0 ; or simply (print (fruits 'apple)) ; ==> 0 ; or simply with default (for non existent enumeration key) value (print (frui...
http://rosettacode.org/wiki/Elementary_cellular_automaton/Random_Number_Generator
Elementary cellular automaton/Random Number Generator
Rule 30 is considered to be chaotic enough to generate good pseudo-random numbers. As a matter of fact, rule 30 is used by the Mathematica software for its default random number generator. Steven Wolfram's recommendation for random number generation from rule 30 consists in extracting successive bits in a fixed positi...
#zkl
zkl
fcn rule(n){ n=n.toString(2); "00000000"[n.len() - 8,*] + n } fcn applyRule(rule,cells){ cells=String(cells[-1],cells,cells[0]); // wrap edges (cells.len() - 2).pump(String,'wrap(n){ rule[7 - cells[n,3].toInt(2)] }) } fcn rand30{ var r30=rule(30), cells="0"*63 + 1; // 64 bits (8 bytes), arbitrary n:=0; ...
http://rosettacode.org/wiki/Empty_string
Empty string
Languages may have features for dealing specifically with empty strings (those containing no characters). Task   Demonstrate how to assign an empty string to a variable.   Demonstrate how to check that a string is empty.   Demonstrate how to check that a string is not empty. Other tasks related to string oper...
#Bracmat
Bracmat
( :?a & (b=) & abra:?c & (d=cadabra) & !a: { a is empty string } & !b: { b is also empty string } & !c:~ { c is not an empty string } & !d:~ { neither is d an empty string } )  
http://rosettacode.org/wiki/Empty_string
Empty string
Languages may have features for dealing specifically with empty strings (those containing no characters). Task   Demonstrate how to assign an empty string to a variable.   Demonstrate how to check that a string is empty.   Demonstrate how to check that a string is not empty. Other tasks related to string oper...
#Burlesque
Burlesque
  blsq ) "" "" blsq ) ""nu 1 blsq ) "a"nu 0  
http://rosettacode.org/wiki/Empty_directory
Empty directory
Starting with a path to some directory, determine whether the directory is empty. An empty directory contains no files nor subdirectories. With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other...
#Julia
Julia
# v0.6.0 isemptydir(dir::AbstractString) = isempty(readdir(dir))   @show isemptydir(".") @show isemptydir("/home")  
http://rosettacode.org/wiki/Empty_directory
Empty directory
Starting with a path to some directory, determine whether the directory is empty. An empty directory contains no files nor subdirectories. With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other...
#Kotlin
Kotlin
// version 1.1.4   import java.io.File   fun main(args: Array<String>) { val dirPath = "docs" // or whatever val isEmpty = (File(dirPath).list().isEmpty()) println("$dirPath is ${if (isEmpty) "empty" else "not empty"}") }
http://rosettacode.org/wiki/Empty_directory
Empty directory
Starting with a path to some directory, determine whether the directory is empty. An empty directory contains no files nor subdirectories. With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other...
#Lasso
Lasso
dir('has_content') -> isEmpty '<br />' dir('no_content') -> isEmpty