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
| (1..100).each do |n| | |
| if n % 3 != 0 && n % 5 != 0 then | |
| print n | |
| end | |
| if n % 3 == 0 then | |
| print "Fizz" | |
| end | |
| if n % 5 == 0 then | |
| print "Buzz" | |
| 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 basic(): | |
| for i in range(1, 101, 1): | |
| cond1 = (i % 3 == 0) | |
| cond2 = (i % 5 == 0) | |
| cond3 = cond1 and cond2 | |
| if cond3: | |
| print(i, 'FizzBuzz') | |
| elif cond2: |
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 NabeatsuCore | |
| def is_fizz?(num) | |
| is_convert?(num, 3) | |
| end | |
| def is_buzz?(num) | |
| is_convert?(num, 5) | |
| 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
| function fizzbuzz(num) { | |
| for (var i = 1; i < num + 1; i++) { | |
| if(i % 15 === 0) { | |
| console.log("fizzbuzz"); | |
| continue; | |
| } | |
| if(i % 3 === 0) { | |
| console.log("fizz") | |
| continue; | |
| } |
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 AppendAccessControlForDevEnv : Jooby.Module { | |
| override fun configure(env: Env?, conf: Config?, binder: Binder?) { | |
| if (env != null) { | |
| env.router().get("*") {req, rsp -> | |
| rsp.header("Access-Control-Allow-Origin", "http://localhost:8090") | |
| } | |
| } | |
| } | |
| } |
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(クラス) : | |
| // データと関数 をひとまとめにした入れ物の定義(型)。 | |
| // 一般に、クラスが持つデータのことを「フィールド」、 | |
| // クラスが持つ関数のことを「メソッド」と呼ぶ。 | |
| // メソッドは引数で値を与えられなくても、自身のフィールドを | |
| // 使うことができる。 | |
| // | |
| // instance(インスタンス) : |
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(クラス) : | |
| // データと関数 をひとまとめにした入れ物の定義(型)。 | |
| // 一般に、クラスが持つデータのことを「フィールド」、 | |
| // クラスが持つ関数のことを「メソッド」と呼ぶ。 | |
| // メソッドは引数で値を与えられなくても、自身のフィールドを | |
| // 使うことができる。 | |
| // | |
| // instance(インスタンス) : |
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
| ///<reference path="../../typings/bundle.d.ts" /> | |
| import * as React from 'react'; | |
| import * as ReactDOM from 'react-dom'; | |
| interface HelloWorldProps {}; | |
| interface HelloWorldStates {}; | |
| class HelloWorld extends React.Component<HelloWorldProps, HelloWorldStates> { | |
| render() { |
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
| # -*- encoding: utf-8 -*- | |
| require 'benchmark/ips' | |
| def fib_naive(n) | |
| return 1 if n <= 2 | |
| fib_naive(n - 1) + fib_naive(n - 2) | |
| end | |
| def fib_memo(n) | |
| fib_memo_recur(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
| a = 1.tap {|i| puts i + i} | |
| a # => 1 | |
| b = 1.tap {|i| break i + i} | |
| b # => 2 | |
| # >> 2 | |
| #lam = lambda {|i| return 1} |