Convert carriage return and line feed to line feed (UNIX line ending).
All checks were successful
The build was successful.
All checks were successful
The build was successful.
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
class Program {
|
||||
private callback $condition = bool(int $x) { return ($x > 100); };
|
||||
private int[] $numbers = {34, 56, 22, 1, 5, 67, 897, 123, 55, 101};
|
||||
|
||||
int[] filter(callback $condition, int[] $numbers) {
|
||||
int $len = sizeof($numbers);
|
||||
int[] $filtered;
|
||||
for(int $i = 0; $i < $len; $i++) {
|
||||
if($condition($numbers[$i])) {
|
||||
$filtered[] = $numbers[$i];
|
||||
}
|
||||
}
|
||||
return $filtered;
|
||||
}
|
||||
|
||||
void main() {
|
||||
int[] $filtered = $this->filter($this->condition, $this->numbers);
|
||||
var_dump($filtered);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Should output
|
||||
|
||||
Array ( [0] => 897 [1] => 123 )
|
||||
*/
|
||||
class Program {
|
||||
private callback $condition = bool(int $x) { return ($x > 100); };
|
||||
private int[] $numbers = {34, 56, 22, 1, 5, 67, 897, 123, 55, 101};
|
||||
|
||||
int[] filter(callback $condition, int[] $numbers) {
|
||||
int $len = sizeof($numbers);
|
||||
int[] $filtered;
|
||||
for(int $i = 0; $i < $len; $i++) {
|
||||
if($condition($numbers[$i])) {
|
||||
$filtered[] = $numbers[$i];
|
||||
}
|
||||
}
|
||||
return $filtered;
|
||||
}
|
||||
|
||||
void main() {
|
||||
int[] $filtered = $this->filter($this->condition, $this->numbers);
|
||||
var_dump($filtered);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Should output
|
||||
|
||||
Array ( [0] => 897 [1] => 123 )
|
||||
*/
|
||||
|
@@ -23,6 +23,6 @@ class Program {
|
||||
}
|
||||
|
||||
|
||||
/* Should output
|
||||
---------------This is some text------------
|
||||
*/
|
||||
/* Should output
|
||||
---------------This is some text------------
|
||||
*/
|
||||
|
@@ -1,36 +1,36 @@
|
||||
class Operations {
|
||||
|
||||
public callback ops(int $x, int $y, string $op){
|
||||
switch($op) {
|
||||
case 'ADD':
|
||||
return int() using ($x, $y) {
|
||||
return $x + $y;
|
||||
};
|
||||
break;
|
||||
case 'SUB':
|
||||
return int() using ($x, $y) {
|
||||
return $x - $y;
|
||||
};
|
||||
break;
|
||||
default:
|
||||
return string() {
|
||||
return 'Operation is not supported by class.';
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Program {
|
||||
|
||||
void main() {
|
||||
callback $fn;
|
||||
object $op = new Operations();
|
||||
$fn = $op->ops(6, 7, 'ADD');
|
||||
print($fn() + "\n");
|
||||
$fn = $op->ops(6, 2, 'SUB');
|
||||
print($fn() + "\n");
|
||||
$fn = $op->ops(6, 7, 'MUL');
|
||||
print($fn() + "\n");
|
||||
}
|
||||
|
||||
}
|
||||
class Operations {
|
||||
|
||||
public callback ops(int $x, int $y, string $op){
|
||||
switch($op) {
|
||||
case 'ADD':
|
||||
return int() using ($x, $y) {
|
||||
return $x + $y;
|
||||
};
|
||||
break;
|
||||
case 'SUB':
|
||||
return int() using ($x, $y) {
|
||||
return $x - $y;
|
||||
};
|
||||
break;
|
||||
default:
|
||||
return string() {
|
||||
return 'Operation is not supported by class.';
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Program {
|
||||
|
||||
void main() {
|
||||
callback $fn;
|
||||
object $op = new Operations();
|
||||
$fn = $op->ops(6, 7, 'ADD');
|
||||
print($fn() + "\n");
|
||||
$fn = $op->ops(6, 2, 'SUB');
|
||||
print($fn() + "\n");
|
||||
$fn = $op->ops(6, 7, 'MUL');
|
||||
print($fn() + "\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,25 +1,25 @@
|
||||
class Program {
|
||||
|
||||
string cycle(char $a, char $b, int $i = 0) {
|
||||
static char[] $switches;
|
||||
if($switches[$i])
|
||||
$switches[$i] = !$switches[$i];
|
||||
else
|
||||
!($switches[$i] = true);
|
||||
return ($switches[$i]) ? $a : $b;
|
||||
}
|
||||
|
||||
void main() {
|
||||
class Program {
|
||||
|
||||
string cycle(char $a, char $b, int $i = 0) {
|
||||
static char[] $switches;
|
||||
if($switches[$i])
|
||||
$switches[$i] = !$switches[$i];
|
||||
else
|
||||
!($switches[$i] = true);
|
||||
return ($switches[$i]) ? $a : $b;
|
||||
}
|
||||
|
||||
void main() {
|
||||
int $i, $j, $k;
|
||||
for($i = 1; $i < 3; $i++) {
|
||||
print($i + $this->cycle('a', 'b') + PHP_EOL);
|
||||
for($j = 1; $j < 5; $j++) {
|
||||
print(' ' + $j + $this->cycle('a', 'b', 1) + PHP_EOL);
|
||||
for($k = 1; $k < 3; $k++) {
|
||||
print(' ' + $k + $this->cycle('c', 'd', 2) + PHP_EOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for($i = 1; $i < 3; $i++) {
|
||||
print($i + $this->cycle('a', 'b') + PHP_EOL);
|
||||
for($j = 1; $j < 5; $j++) {
|
||||
print(' ' + $j + $this->cycle('a', 'b', 1) + PHP_EOL);
|
||||
for($k = 1; $k < 3; $k++) {
|
||||
print(' ' + $k + $this->cycle('c', 'd', 2) + PHP_EOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user