最近研究でCoqぐらいしか書いてないので、リハビリがてらAtCoderで 開かれるコンテストにOCamlで参加して遊んでます。 僕は個人的な趣味もあってOCamlを使う際は専ら言語処理系を書いていましたが、 競技プログラミングでは全く関係ない題材を扱う必要があるので新鮮な感じですね。 それに伴って有名なアルゴリズムもいくつか実装したので、 ここではそういうアルゴリズムをMLではどう書いたのか紹介したいなと思います。 高速なべき乗のアルゴリズム 正式名称はよく分からないのですが、ありますよね?O(log n)でべき乗を計算するアルゴリズム。 x ^ nを計算する時、nが偶数の時は(x * x) ^ (n / 2)とみなすやつです。 OCamlで素朴に実装するとこんな感じ。 let rec power m = function | 0 -> 1. | n when n mod 2 = 0 ->
Dijkstra's algorithm You are encouraged to solve this task according to the task description, using any language you may know. This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task. Dijkstra's algorithm, conceived by Dutch computer scientist Edsger Dijkstra in 1956 and published in 1959, is a graph search algorithm t
To set the tone for future posts, today I’d like to discuss Clojure. In short, Clojure is a Lisp dialect that targets the Java Virtual machine, so you can use all the Java libraries out there. I have been playing with Clojure for a couple of years now, using it at work since last year. To give you a taste of the language, check out this extremely concise implementation of Dijkstra’s shortest-path
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く