配列操作の比較表: Ruby, AppleScript, HyperCard

いやなブログ: 配列操作の比較表: Ruby, Python, JavaScript, Perl, C++
の AppleScript 版
HyperCard はふざけた丈け (配列が存在しない――単なる文字列)

Ruby (Array) AppleScript (List) HyperCard (Items)
a = [1, 2, 3] set a to {1, 2, 3}
copy {1, 2, 3} to a
{1, 2, 3} returning a
put "1,2,3" into a
a.length length of a
a's length
count every item of a
count a's every item
count items of a
count a's items
number of every item of a
number of a's every item
number of items of a
number of a's items
the number of items of a
a.empty? a = {} a is empty
a.push(x) set end of a to x
set a's end to x
copy x to end of a
copy x to a's end
x returning end of a
x returning a's end
put the itemDelimiter & x after a
put x after item (1 + the number of items of a) of a
a.unshift(x) set front of a to x
set a's front to x
copy x to front of a
copy x to a's front
x returning front of a
x returning a's front
put x & the itemDelimiter before a
a.pop function が必要

on pop(L)
if L's contents's length = 0 then return {}
copy L's contents's last item to popItem
copy L's contents's items 1 thru -2 to L's contents
return popItem
end pop

pop(a reference to a)
2 文に分けて

get last item of a
delete last item of a
a.shift function が必要

on shift(L)
if L's contents's length = 0 then return {}
copy L's contents's first item to shiftItem
copy L's contents's rest to L's contents
return shiftItem
end shift

shift(a reference to a)
2 文に分けて

get first item of a
delete first item of a
a.concat(b) set a to a & b
copy a & b to a
a & b returning a
put the itemDelimiter & b after a
put b after item (1 + the number of items of a) of a
a.clear set a to {}
copy {} to a
{} returning a
put empty into a
a.insert(i, x) set a to items 1 thru (i - 1) of a & x & items i thru end of a
copy items 1 thru (i - 1) of a & x & items i thru end of a to a
items 1 thru (i - 1) of a & x & items i thru end of a returning a
put x & the itemDelimiter before item i of a
a.delete(x) function が必要

on deleteitem of x from r
set temp to {}
repeat with i in r's contents
get i as item
if result is not x then set temp's end to result
end repeat
set r's contents to temp
end deleteitem

deleteitem of x from a reference to a
delete item (the number of items of char 1 to offset(the itemDelimiter & x & the itemDelimiter, the itemDelimiter & a & the itemDelimiter) - 1) of a of a
a.delete_at(i) set a to items 1 thru (i - 1) of a & items (i + 1) thru end of a
copy items 1 thru (i - 1) of a & items (i + 1) thru end of a to a
items 1 thru (i - 1) of a & items (i + 1) thru end of a returning a
delete item i of a
a.include?(x) x is in a offset(the itemDelimiter & x & the itemDelimiter, the itemDelimiter & a & the itemDelimiter) is not 0
a.index(x) the number of items of char 1 to offset(the itemDelimiter & x & the itemDelimiter, the itemDelimiter & a & the itemDelimiter)
a.first first item of a
a's first item
1st item of a
a's 1st item
item 1 of a
a's item 1
first item of a
item one of a
item 1 of a
a.last
a[-1]
last item of a
a's last item
item -1 of a
a's item -1
last item of a
a[i,l]
a.slice(i, l)
items i thru (i + l) of a
a's items i thru (i + l)
item i to i+l of a
a[i..j]
a.slice(i..j)
items i thru j of a
a's items i thru j
item i to j of a
a[i...j]
a.slice(i...j)
items i thru (j - 1) of a
a's items i thru (j - 1)
item i to j-1 of a
a.sort! sort items of a
a.each { |x|
...
}
repeat with x in a
...
end repeat
repeat with i = 1 to the nmber of items of a
put item i of a into x
...
end repeat
2010年06月09日(水) 05:29:41 Modified by ID:9IihpDzSDw




スマートフォン版で見る

×

この広告は60日間更新がないwikiに表示されております。