Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.
You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.
A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.
Taking a look at Igloo testing framework.
I think there must be some automatical header generation going on here...
template <class T, class U>
auto add(const T& x, const U& y) {
return x + y;
}
#include <string>
using namespace std::string_literals;
Describe(generic_add)
{
It(should_add_numbers)
{
Assert::That(add(2, 2), Equals(4));
}
It(should_add_strings)
{
Assert::That(add("2"s, "2"s), Equals("22"s));
}
};
//
Describe(tests)
{
It(should_do_something_0)
{
Assert::That(1, Equals(2));
}
It(should_do_something_1)
{
Assert::That(123, Equals(456));
}
It(should_do_something_2)
{
Assert::That('a', Equals('b'));
}
};
#include <algorithm>
#include <iterator>
#include <random>
#include <vector>
void run() {
using namespace std;
// this is a source of true random numbers
random_device rd;
// it's used to generate a seed for an engine
default_random_engine eng(rd());
// distribution is applied to a generator to generate random numbers
uniform_int_distribution<int> dist(1, 10);
vector<int> xs;
for (unsigned i = 0; i < 20; i++)
xs.push_back(dist(eng));
for (int x : xs)
cout << x << ' ';
cout << '\n';
}
void run2() {
using namespace std;
default_random_engine eng{random_device()()};
uniform_int_distribution<int> dist(1, 10);
auto rand10 = [&eng, &dist]() { return dist(eng); };
vector<int> xs;
generate_n(back_inserter(xs), 20, rand10);
copy(cbegin(xs), cend(xs), ostream_iterator<int>(cout, " "));
cout << '\n';
}
Describe(any_group_name_you_want)
{
It(should_do_something)
{
run();
run2();
Assert::That(true, Is().True());
}
};
Test of the codewars array test case
var array = ['codewars'];
// Create your own tests here using the Test package (https://github.com/dart-lang/test)
// Here is some boilerplate:
test('The array should not be empty', () {
expect(array.length, greaterThan(0));
expect(array.length, equals(1));
expect(array[0], equals('codewars'));
});
let rec sumMult i k n = if i + k < n then i + sumMult (i + k) k n else i
let sumOfMultiples list n = list |> List.map(fun x -> sumMult 0 x n) |> List.sum
printfn "%A" (sumOfMultiples [1; 2; 3] 10)
let rec sumMult i k n = if i + k < n then i + sumMult (i + k) k n else i
let sumOfMultiples list n = list |> List.map(fun x -> sumMult 0 x n) |> List.sum
let v = sumOfMultiples [7; 13; 17] 20
printfn "%A" v
Contains random dart tests
class Person {
String firstName;
String lastName;
Person(this.firstName,this.lastName);
}
// Create your own tests here using the Test package (https://github.com/dart-lang/test)
// Here is some boilerplate:
test('Should be able to create a Person object', () {
expect(new Person('Bill', 'Smith'), new isInstanceOf<Person>());
});
test('Person object has expected name', () {
var p = new Person('Bill', 'Smith');
expect(p.firstName, equals('Bill'));
expect(p.lastName, equals('Smith'));
});
http://www.willamette.edu/~fruehr/haskell/seuss.html
A parser for a thing
Is a function from a string
To a list of pairs
Of things and strings!
This monadic parser is missing many basic functions and several important typeclass instances.
{-# LANGUAGE DeriveFunctor, TupleSections #-}
module MonadicParsing where
newtype Parser a = Parser { runParser :: String -> [(a, String)] }
deriving Functor
instance Monad Parser where
return a = Parser $ return . (a,)
Parser p >>= f = Parser $ \s -> concatMap (uncurry (runParser.f)) $ p s
import Data.Char
import Data.List
import Test.Hspec
import MonadicParsing (Parser (..))
main :: IO ()
main = hspec spec
takeParser :: Int -> Parser String
takeParser l = Parser $ \s -> [(take l s, drop l s)]
digitParser :: Parser Int
digitParser = Parser $ \s -> [ (digitToInt a, drop 1 s) | a <- take 1 s, isDigit a ]
repeatParser :: Show a => a -> Parser a
repeatParser a = Parser $ \s -> [(a, drop l s) | t `isPrefixOf` s]
where
t = show a
l = length t
spec :: Spec
spec = do
describe "monad instance" $ do
it "left identity" $ runParser (return 3 >>= takeParser) "hello"
`shouldBe` runParser (takeParser 3) "hello"
it "right identity" $ runParser (takeParser 9 >>= return) "world"
`shouldBe` runParser (takeParser 9) "world"
it "associativity" $ runParser ((digitParser >>= repeatParser) >>= takeParser) "99 luftballons"
`shouldBe` runParser (digitParser >>= (\x -> repeatParser x >>= takeParser)) "99 luftballons"
let addOne = fun x -> x + 1
let value = addOne <| 1 |> addOne
printfn "%i" value
let rec print list =
match list with
| [] -> ()
| head::rest -> head |> printfn "%O"; print(rest)
print [1; 5; 7]