def isMin(val,arr): match arr: case []: return True case _: return val<=arr[0] and isMin(val,arr[1:]) def findMin(i,arr): match isMin(arr[i],arr): case True: return arr[i] case _: return findMin(i+1,arr) def remove(target,arr): match arr: case []: return [] case _: return arr[1:] if target==arr[0] else [arr[0]]+remove(target,arr[1:]) def select(arr): match arr: case []: return [] case _: m=findMin(0,arr) arr=remove(m,arr) return [m]+select(arr) print(1)
- def isMin(val,arr):
- match arr:
- case []:
- return True
- case _:
- return val<=arr[0] and isMin(val,arr[1:])
- def findMin(i,arr):
- match isMin(arr[i],arr):
- case True:
- return arr[i]
- case _:
- return findMin(i+1,arr)
- def remove(target,arr):
- match arr:
- case []:
- return []
- case _:
- return arr[1:] if target==arr[0] else [arr[0]]+remove(target,arr[1:])
- def select(arr):
- match arr:
- case []:
- return []
- case _:
- m=findMin(0,arr)
- arr=remove(m,arr)
return [m]+select(arr)- return [m]+select(arr)
- print(1)
rt
$a=1;
<?php
use PHPUnit\Framework\TestCase;
// PHPUnit Test Examples:
// TODO: Replace examples and use TDD by writing your own tests
class ExampleTest extends TestCase
{
// test function names should start with "test"
public function testThatSomethingShouldHappen() {
$this->assertEquals(a(1), 1);
}
}