Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Created August 30, 2015 03:15
Show Gist options
  • Save yutannihilation/6245d9b894b498d3e059 to your computer and use it in GitHub Desktop.
Save yutannihilation/6245d9b894b498d3e059 to your computer and use it in GitHub Desktop.
Wolfram Languageを使ってみる

データ型

配列?

ドキュメントがうまく見つけられないので以下は推測。

同じ型の値しかもたない。

[1, 2, 3]
["a", "b", "c"]

Subset

配列から値を取り出すには[[ ]]を使う。

["a", "b", "c"][[2]]
#> ["b"]

範囲指定もできるっぽいけどよく分からない。。

["a", "b", "c"][[2 ;; 3]]

リスト

参考: リスト | Wolfram言語プログラミングの基本

配列?と違って、どんな値でも入れられる。

例にはこれが載ってるけど、WolframAlphaではsphere[]が動かないのでうまく結果が出ない。

{1, 2, 3, "a", sphere[]}

Subset

配列?と同じ。

{1, 2, 3, "a"}[[2]]
{1, 2, 3, "a"}[[2 ;; 4]]

反復子

http://www.wolframalpha.com/input/?i=Table&a=*C.Table-_*WolframLanguageSymbol-

Table[式, {変数1, 値}, {変数2, 値}...]

とやると、変数1と変数2の組み合わせを評価してくれる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment