This file contains 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
Here is my program lang. Could you provide number guessing game in the lang? | |
const readline = require('readline'); | |
const fs = require('fs'); | |
const readLineSync = require('readline-sync'); | |
function input(prompt) { | |
return readLineSync.question(prompt); | |
} | |
//プログラム全体 |
This file contains 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
// Program class | |
class Program { | |
constructor(defs, ...expressions) { | |
this.defs = defs; | |
this.expressions = expressions; | |
} | |
} // Function definition class | |
class FunDef { | |
constructor(name, args, body) { | |
this.name = name; |
This file contains 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
もちろんです!以下に、Chrome拡張機能を作成するためのコードの例を示します。これは、指定された仕様を満たすシンプルな拡張機能です。 | |
まず、プロジェクトディレクトリに3つのファイルを作成してください。 | |
manifest.json | |
background.js | |
content.js | |
manifest.json: |
This file contains 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 doPost(e) { | |
// slack appsのEvent Subscriptionsのchallenge。同期する時に利用。 | |
var params = JSON.parse(e.postData.getDataAsString()); | |
if('challenge' in params) | |
{ | |
return ContentService.createTextOutput(params.challenge); | |
} | |
// ユーザ名とtextを取得 | |
var userName = params.event.user; |
This file contains 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
以下の日本語をプログラムとして解釈して実行してください。 | |
ほげ数を計算(N) | |
・もし、N < 2 なら1を返す | |
・そうでなければ、「N * ほげ数を計算(N - 1)」を返す | |
ほげ数を計算(10) |
This file contains 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 public DifferentReturnTypes | |
.super java/lang/Object | |
; | |
; standard initializer | |
.method public <init>()V | |
aload_0 | |
invokenonvirtual java/lang/Object/<init>()V | |
return |
This file contains 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
scala> def from(n: Int): LazyList[Int] = LazyList.cons(n, from(n + 1)) | |
def from(n: Int): LazyList[Int] | |
scala> from(0).take(10).toList | |
val res0: List[Int] = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) |
This file contains 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 com.github.kmizu.scomb._ | |
object Calculator1 extends SCombinator[Int] { | |
def root: Parser[Int] = expression | |
def expression: Parser[Int] = rule(A) | |
def A: Parser[Int] = rule(chainl(M) { | |
$("+").map { op => (lhs: Int, rhs: Int) => lhs + rhs } | | |
$("-").map { op => (lhs: Int, rhs: Int) => lhs - rhs } |
This file contains 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 java.util.*; | |
import java.awt.Point; | |
public class NQueen { | |
public static final String ANSI_GREEN = "\u001B[32m"; | |
public static final String ANSI_RESET = "\u001B[0m"; | |
public static final String ANSI_WHITE = "\u001B[37m"; | |
private final int N; | |
private final Set<Point> queens; | |
public NQueen(int N) { | |
this.N = N; |
This file contains 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 org.scalatest.BeforeAndAfterAll | |
import org.scalatest.fixture.FunSpec | |
import scalikejdbc.{DB, _} | |
import scalikejdbc.config.DBs | |
import scalikejdbc.scalatest.AutoRollback | |
class ReservationRepositorySpec extends FunSpec with AutoRollback with BeforeAndAfterAll { | |
//テスト実行前にダミーデータを追加 | |
override def beforeAll(): Unit = { |
NewerOlder