Start a new Kumite
AllAgda (Beta)BF (Beta)CCFML (Beta)ClojureCOBOL (Beta)CoffeeScriptCommonLisp (Beta)CoqC++CrystalC#D (Beta)DartElixirElm (Beta)Erlang (Beta)Factor (Beta)Forth (Beta)Fortran (Beta)F#GoGroovyHaskellHaxe (Beta)Idris (Beta)JavaJavaScriptJulia (Beta)Kotlinλ Calculus (Beta)LeanLuaNASMNim (Beta)Objective-C (Beta)OCaml (Beta)Pascal (Beta)Perl (Beta)PHPPowerShell (Beta)Prolog (Beta)PureScript (Beta)PythonR (Beta)RacketRaku (Beta)Reason (Beta)RISC-V (Beta)RubyRustScalaShellSolidity (Beta)SQLSwiftTypeScriptVB (Beta)
Show only mine

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.

Ad
Ad

Spawning a more complex function as a process.

Proc = fun(Y, Items) ->
	receive
  	Item when is_atom(Item) -> 
    	io:format("~p added.~n", [Item]),
      Y(Y, [Item | Items]);
    _ -> io:format("Killing Fridge...")
  end
end,

Pid = spawn(fun() -> Proc(Proc, []) end),

Pid ! beer,
Pid ! salsa,
Pid ! soda,
Pid ! eggs,
Pid ! steak,
Pid ! pudding,

init:stop().
Code
Diff
  • ++++ +++  ; Adds 7
    [           ; Enters a loop
      >         ; Moves forward
      ++++ +++  ; Adds 7
      <         ; Moves back
      -         ; Removes 1
    ]         ; 0 = 0, 1 = 49 (ASCII for '1')
    >         ; Moves back to 1
    .         ; Prints idx 1 val 49 | '1'
    -         ; Subtracts 1
    ..        ; Prints idx 1 val 48 | '0' twice
    • function returnhundred() {
    • return 10 ** 2;
    • }
    • ++++ +++ ; Adds 7
    • [ ; Enters a loop
    • > ; Moves forward
    • ++++ +++ ; Adds 7
    • < ; Moves back
    • - ; Removes 1
    • ] ; 0 = 0, 1 = 49 (ASCII for '1')
    • > ; Moves back to 1
    • . ; Prints idx 1 val 49 | '1'
    • - ; Subtracts 1
    • .. ; Prints idx 1 val 48 | '0' twice
Proc = fun () -> 
	io:format("Hello Process.~n")
end,

Pid = spawn(Proc),

io:format(" Hello's Pid: ~p~n", [Pid]),

init:stop().
Arrays
Data Types
Functions
Control Flow
Basic Language Features
Fundamentals
Language Syntax
Declarative Programming
Programming Paradigms
Lambdas
Functional Programming
Higher-order Functions

Javascript function-based Array 'syntax':

 This is an interesting kata that I came across today*, in which a function was called in this kind of fashion, previously unseen by me:

someFunction(6)()()(2)()()(1).end();  // Wierd, right?

 To an experienced JavaScripter, this will immediately seem clear: The function is returning another function, that returns itself, and has a method end() to 'terminate' the chain.

Interested by this, I made this kumite describing a similar function that would create an Array. I also changed end to a variable rather than a function, because one, I'm addicted to ruby** syntax, and two, it's generally easier on the fingers!

// 'chain(arg)...(arg).end;' is equivalent to '[arg...arg];'

chain().end;               // [null]
chain(1)(2)(3).end         // [1, 2, 3]
chain('hey')()(true).end   // ['hey', null ,true]

Suggestions for future forks:

  • Improve the syntax further: Add a bit of syntax to describe repetition of an element, maybe chain(6)(3,2)(6) => [6,3,3,6]?
  • Make this in other languages: Is it possible? How, or why not?
  • Refactor this code: I'm pretty sure I've got this nailed, but I'd still like to see how other people do it!

* This kumite was inspired by this kata, which I really reccomend having a shot at.

** I can't seem to create a Ruby equivalent, If you work out how, please make a fork!

// This is just an interesting alternative way to build an array,
// almost like a declarative literal - Very cool stuff!

// See test cases for syntax.

function chain(element) {
  var array = [element];
  var sectionBuilder = function(elem) {
    array.push(elem);
    sectionBuilder.end = array;
    return sectionBuilder;
  };
  sectionBuilder.end = array;
  return sectionBuilder;
}

I decided to test the java framework.

My opinions:

-I just started learning python, and in comparison, it takes a lot more to set up the tests in java, mostly beacause you have to set up the class and methods. Not much can be done about that anyway though.

-It takes a while to start up, and I even got some timeouts on something this simple. I assume the JVM that takes this much time to start up.

-I do miss eclipse's hability to automatiaclly indent and add the missing "}" when you press enter while the cursor is right after a "{". That would speed up setting up stuff.

-After so much programming in python and not much java, I found myself consistently forgetting to add ";" :P

Note:

I copied most stuff from https://github.com/Codewars/kata-test-framework-java , under CodewarsJava/src.
I found the int's in the beggining of the tester class to be completly useless in a test this simple though.

Also, just wanted to point out that in that kata in the git repository the assertEquals, in case of fail will print the error message, and after that the failed method will be called, which prints it again, causing it to print the exact same thing twice.

Notes to self and others that want to try making a java kumite:

To start a kumite, must set up:
-Class with the name of the test
-A class with the same name plus "Test"
-Create a member instante of the first class within the test.
-Create public void setUp() and tearDown() with @Before and @After anotations.
-Make the method that will test the kata or kumite, with a @Test anotation
-Create an instance of TestWatcher, with @Rule anotation, overriding both protected final void succeeded(Description description) and failed(Throwable e, Description description)

Hope this is useful to others.
Thanks for reading :)

PS: Sorry if my english is not the best, I'm not a native speaker.

public class Java {
  public int multiply(int x, int y) {
    return x * y;
  }
}
Fundamentals
#include<stdio.h>

int main() {
  printf("Hello, C!\n");
}

Checking to see if the clojure runner has the same problems as the Java runner. Apparently not...

(ns codewars.sanity.check)

(defn multiply [ & args ] (apply * args))