This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Either is OK. | |
| // abstract Base { def say(word: String) } | |
| trait Base { def say(word: String) } | |
| class Hoge extends Base { def say(word: String) = println(word) } | |
| trait Smile extends Base { abstract override def say(word: String) = super.say(word + " :)") } | |
| trait Hello extends Base { abstract override def say(word: String) = super.say("Hello " + word) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let ($) f g = f g | |
| let rec perm xs n l total = | |
| if n <= 0 then l::total | |
| else begin | |
| List.flatten $ | |
| List.map (fun c -> perm xs (n - 1) (c::l) total) xs | |
| end | |
| let rec perm2 xs n = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.komamitsu.hashcodetest | |
| /** | |
| * @author komamitsu | |
| */ | |
| case class Foo(id: Int) | |
| case class Bar(id: Int) | |
| class Hoge(foo: Foo, bar: Bar) { | |
| override def hashCode : Int = foo.## + bar.## | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <string.h> | |
| static void p(int xs[], int s, int e) { | |
| int i; | |
| printf("["); | |
| for (i = s; i <= e; i++) { | |
| printf("%d ", xs[i]); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BmStringSearch | |
| def initialize(target) | |
| @target = target | |
| @skip = {} | |
| i = target.size - 1 | |
| target.each_char do |x| | |
| @skip[x] = i | |
| i -= 1 | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def sort(xs, st, en) | |
| pivot = xs[st] | |
| s, e = st + 1, en | |
| loop do | |
| while (s <= en && xs[s] < pivot) | |
| s += 1 | |
| end | |
| while (e > st && pivot < xs[e]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let pickout xs index = | |
| let (_, opt, rest) = | |
| List.fold_left | |
| (fun (i, opt, rest) x -> | |
| if i = index then (i + 1, Some x, rest) | |
| else (i + 1, opt, x::rest)) (0, None, []) xs | |
| in | |
| match opt with | |
| | None -> failwith "not found" | |
| | Some x -> (x, rest) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void bench() { | |
| StringBuilder buf = new StringBuilder(); | |
| for (int i = 0; i<100000; i++) | |
| buf.append("0123456789あいうえおaiueo"); | |
| String s = buf.toString(); | |
| byte[] bytes = s.getBytes(); | |
| char[] chars = s.toCharArray(); | |
| long start = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0"?> | |
| <root> | |
| <item> | |
| <name>Komamitsu's setting</name> | |
| <identifier>private.komamitsu</identifier> | |
| <autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::VK_JIS_TOGGLE_EISUU_KANA</autogen> | |
| <autogen>__KeyToKey__ KeyCode::JIS_EISUU, KeyCode::CONTROL_L</autogen> | |
| <autogen>__KeyToKey__ KeyCode::JIS_KANA, KeyCode::ESCAPE</autogen> | |
| </item> | |
| </root> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "Foundation/Foundation.h" | |
| @interface User : NSObject | |
| - (NSString*)hello:(NSString*)msg; | |
| @property(copy) NSString *name; | |
| @property int age; | |
| @end |