Balanced brackets: Difference between revisions
→{{header|AppleScript}}
Line 475:
script mf
on bracket(_)
"["▼
else▼
"]"▼
end if▼
end bracket
end script
Line 492 ⟶ 488:
set lngChars to length of xs
if lngChars > 0 then
end if▼
if iNext < 0 then -- closing bracket unmatched
Line 504 ⟶ 496:
errorIndex(items 2 thru -1 of xs, iNext, iIndex + 1)
else -- end of string
end if
end if
else
end if
end errorIndex
Line 539 ⟶ 523:
set blnOK to (i = -1)
else▼
end if▼
set strLine to "'" & s & "'" & ¬
(items (w + 2) thru -1 of strPad) & strStatus
set strPointer to iff(blnOK,
intercalate("", {strLine, strPointer})
end report
Line 611 ⟶ 589:
return o & s
end nreps
-- Value of one of two expressions
-- Bool -> a -> b -> c
on iff(bln, f, g)
if bln then
if class of e is handler then
mReturn(e)'s lambda()
end iff
-- Lift 2nd class function into 1st class wrapper
Line 627 ⟶ 620:
property lambda : f
end script
end mClosure
</lang>
{{Out}}
Line 634 ⟶ 628:
'' OK
'[]' OK
'][[
^
'[]]
^
'
']]][][]][]' problem▼
^
'
=={{header|AutoHotkey}}==
|