Skip to content

Instantly share code, notes, and snippets.

continuousIncrementDecrement : Msg -> Int -> Model -> Model
continuousIncrementDecrement msg num currentCounter =
List.foldl (\_ cc -> update msg cc |> Tuple.first) currentCounter (List.repeat num ())
class MyHash
attr_accessor :table
def initialize
@table = Array.new(100)
end
def get(key)
table[hash(key)]
end
#初期設定
capacity = 500
numOfGene = 20
numOfElement = 50
maxGoodsWeight = 20
maxGoodsValue = 10
weight = Array.new(numOfElement)
value = Array.new(numOfElement)
for i in 0..numOfElement-1
import * as index from '../index';
describe('Tests', () => {
describe('isMan /* index.tsで書いた関数名 */', () => {
it('manなら男' /* 渡した文字列はmanですか? という質問が正しいなら男 */, () => {
expect(index.isMan('man' /* sex = 'man' */)).toBeTruthy();
});
it('womanなら男ではない' /* 渡した文字列はmanですか? という質問が正しくないなら男ではない*/, () => {
expect(index.isMan('woman')).toBeFalsy();
});
import * as index from '../index';
describe('Tests', () => {
describe('isAdult /* index.tsでexportした関数名が入る */', () => {
it('18歳なら大人' /* isAdult(大人ですか?) という質問に対して trueなので大人 */, () => {
expect(index.isAdult(18 /* age */)).toBeTruthy();
});
it('17歳なら子供' /* isAdult(大人ですか?) という質問に対して trueなので子供 */, () => {
expect(index.isAdult(17 /* age */)).toBeFalsy();
});
-- 重い処理の結果、数字を返す関数。Futureと同じ。
-- https://package.elm-lang.org/packages/elm/core/latest/Task#succeed
heavyTask : Int -> Task () Int
heavyTask n =
Task.succeed n
tasks : Int -> String -> Task () String
tasks n result =
heavyTask n
type Tree
= Node Tree Int Tree
| Empty
empty : Int -> Tree
empty v =
Node Empty v Empty
type Tree
= Node Tree Int Tree
| Nil
leaf : Int -> Tree
leaf v =
Node Nil v Nil
jsonResolver : D.Decoder a -> Http.Resolver Http.Error a
jsonResolver decoder =
Http.stringResolver <|
\response ->
case response of
Http.BadUrl_ url ->
Err (Http.BadUrl url)
Http.Timeout_ ->
Err Http.Timeout
module Main exposing (OriginalFoo, json2OriginalFoo)
import Browser
import Html exposing (Html, div, h1, img, text)
import Html.Attributes exposing (src)
import Json.Decode as D exposing (Decoder)
import Task as Task exposing (Task)
type alias OriginalFoo =