tx · 7YL5FjnKr7H67npTjVz73YdDvaCXmd5jPgtviTggjT3Z 3Mr1FdiZzG9iTQUtPmQEs1hBVbyQhG6LU93: -0.01000000 Waves 2023.10.30 20:01 [2821645] smart account 3Mr1FdiZzG9iTQUtPmQEs1hBVbyQhG6LU93 > SELF 0.00000000 Waves
{ "type": 13, "id": "7YL5FjnKr7H67npTjVz73YdDvaCXmd5jPgtviTggjT3Z", "fee": 1000000, "feeAssetId": null, "timestamp": 1698685338476, "version": 1, "sender": "3Mr1FdiZzG9iTQUtPmQEs1hBVbyQhG6LU93", "senderPublicKey": "De2GV53Brxd2GCQnLJWRugSidGtrVvPL9kJn2Dh4NTpJ", "proofs": [ "qbqwBs2tijEMx8eBare8H4Pev5bDvPGPAvJE37qyuQdwbFeyi77ufqBsMTxU4NvYSXp726qPMNybyaijFo1eM1p" ], "script": "base64:BgIaCAISBgoECAgBCBIDCgEEEgMKAQgSBAoCCAJGAANTRVACAl9fAAdXQVZFU0lEAQQTq9kzAAZXQVZFU0QAgMLXLwEMZ2V0U3RyT3JGYWlsAgdhZGRyZXNzA2tleQkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCdCAIFB2FkZHJlc3MFA2tleQkAuQkCCQDMCAICCm1hbmRhdG9yeSAJAMwIAgkApQgBBQdhZGRyZXNzCQDMCAICAS4JAMwIAgUDa2V5CQDMCAICDyBpcyBub3QgZGVmaW5lZAUDbmlsAgABDGdldEludE9yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAmggCBQdhZGRyZXNzBQNrZXkJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuCQDMCAIFA2tleQkAzAgCAg8gaXMgbm90IGRlZmluZWQFA25pbAIAAQ1nZXRCb29sT3JGYWlsAgdhZGRyZXNzA2tleQkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCbCAIFB2FkZHJlc3MFA2tle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MF8yAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgUFJGFjYzAAAAABAAIAAwAEAAUABgAHAAgACQAKBwdTX2Dx", "chainId": 84, "height": 2821645, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EzkncbAfPAMFL7pHEye5HMDz51ASkLNDPprVp3SHupHH Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
6 | + | let WAVESID = base58'WAVES' | |
7 | + | ||
8 | + | let WAVESD = 100000000 | |
9 | + | ||
10 | + | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
11 | + | ||
12 | + | ||
13 | + | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
14 | + | ||
15 | + | ||
16 | + | func getBoolOrFail (address,key) = valueOrErrorMessage(getBoolean(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
17 | + | ||
18 | + | ||
19 | + | let allowedAssetsKey = "%s%s__cfg__allowedAssets" | |
20 | + | ||
21 | + | let assetsDecimalsKey = "%s%s__cfg__assetsDecimals" | |
22 | + | ||
23 | + | let betDividersKey = "%s%s__cfg__assetsBetDividers" | |
24 | + | ||
25 | + | let RSAPUBLIC64KEY = "%s%s__cfg__rsaPublic64" | |
26 | + | ||
27 | + | let SERVERADDRESSKEY = "%s%s__cfg__benzAddress" | |
28 | + | ||
29 | + | let RANDTIMEFRAMEKEY = "%s%s__cfg__withdrawTimeFrame" | |
30 | + | ||
31 | + | let GAMESCOUNTERKEY = "%s%s__runtime__gameNum" | |
32 | + | ||
33 | + | let blockedKey = "%s%s__runtime__contractIsBlocked" | |
34 | + | ||
35 | + | let reservedAmountsKey = "%s%s__runtime__reservedAmounts" | |
36 | + | ||
37 | + | func getIntArray (key) = { | |
38 | + | let a = getStrOrFail(this, key) | |
39 | + | func filler (acc,el) = (acc :+ parseIntValue(el)) | |
40 | + | ||
41 | + | let $l = split(a, SEP) | |
42 | + | let $s = size($l) | |
43 | + | let $acc0 = nil | |
44 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
45 | + | then $a | |
46 | + | else filler($a, $l[$i]) | |
47 | + | ||
48 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
49 | + | then $a | |
50 | + | else throw("List size exceeds 10") | |
51 | + | ||
52 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
53 | + | } | |
54 | + | ||
55 | + | ||
56 | + | func getAssets () = split(getStrOrFail(this, allowedAssetsKey), SEP) | |
57 | + | ||
58 | + | ||
59 | + | let ASSETS = getAssets() | |
60 | + | ||
61 | + | let DECIMALS = getIntArray(assetsDecimalsKey) | |
62 | + | ||
63 | + | let BETDIVIDERS = getIntArray(betDividersKey) | |
64 | + | ||
65 | + | func RESERVATIONKEYBYSTR (assetStr) = ("$RESERVED_AMOUNT_" + assetStr) | |
66 | + | ||
67 | + | ||
68 | + | func RESERVATIONKEY (assetIdx) = RESERVATIONKEYBYSTR(ASSETS[assetIdx]) | |
69 | + | ||
70 | + | ||
71 | + | let MINFEEWAVES = ((5 * WAVESD) / 1000) | |
72 | + | ||
73 | + | let idxAssets = 0 | |
74 | + | ||
75 | + | let idxDecimals = 1 | |
76 | + | ||
77 | + | let idxDividers = 2 | |
78 | + | ||
79 | + | let idxReservation = 3 | |
80 | + | ||
81 | + | let BET1 = 1 | |
82 | + | ||
83 | + | let BET2 = 2 | |
84 | + | ||
85 | + | let BET4 = 4 | |
86 | + | ||
87 | + | let BET8 = 8 | |
88 | + | ||
89 | + | let BET14 = 14 | |
90 | + | ||
91 | + | let RATEMULT = 10000 | |
92 | + | ||
93 | + | let RATE1 = 39655 | |
94 | + | ||
95 | + | let RATE2 = 24600 | |
96 | + | ||
97 | + | let RATE3 = 19000 | |
98 | + | ||
99 | + | let RATE4 = 14200 | |
100 | + | ||
101 | + | let RATE5 = 11400 | |
102 | + | ||
103 | + | let RATES = [RATE1, RATE2, RATE3, RATE4, RATE5] | |
104 | + | ||
105 | + | let BETS = [BET1, BET2, BET4, BET8, BET14] | |
106 | + | ||
107 | + | let IdxGameState = 0 | |
108 | + | ||
109 | + | let IdxPlayerChoice = 1 | |
110 | + | ||
111 | + | let IdxPlayerPubKey58 = 2 | |
112 | + | ||
113 | + | let IdxStartedHeight = 3 | |
114 | + | ||
115 | + | let IdxWinAmount = 4 | |
116 | + | ||
117 | + | let IdxAssetId = 5 | |
118 | + | ||
119 | + | let STATESUBMITTED = "SUBMITTED" | |
120 | + | ||
121 | + | let STATEWON = "WON" | |
122 | + | ||
123 | + | let STATELOST = "LOST" | |
124 | + | ||
125 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (key + " key is not specified in this.state")) | |
126 | + | ||
127 | + | ||
128 | + | let RSAPUBLIC = fromBase64String(getStringOrFail(RSAPUBLIC64KEY)) | |
129 | + | ||
130 | + | let SERVER = addressFromStringValue(getStringOrFail(SERVERADDRESSKEY)) | |
131 | + | ||
132 | + | let RANDORACLETIMEFRAME = valueOrElse(getInteger(this, RANDTIMEFRAMEKEY), 7200) | |
133 | + | ||
134 | + | func getIntOr (key,default) = if (isDefined(getInteger(key))) | |
135 | + | then getIntegerValue(key) | |
136 | + | else default | |
137 | + | ||
138 | + | ||
139 | + | func setInt (key,value) = IntegerEntry(key, value) | |
140 | + | ||
141 | + | ||
142 | + | func incrementInt (key) = setInt(key, (getIntOr(key, -1) + 1)) | |
143 | + | ||
144 | + | ||
145 | + | func changeInt (key,by) = setInt(key, (getIntOr(key, 0) + by)) | |
146 | + | ||
147 | + | ||
148 | + | func assetIdToStr (assetIdOrUnit) = match assetIdOrUnit { | |
149 | + | case b: ByteVector => | |
150 | + | toBase58String(b) | |
151 | + | case _ => | |
152 | + | "WAVES" | |
153 | + | } | |
154 | + | ||
155 | + | ||
156 | + | func assetIdFromStr (assetIdStr) = if ((assetIdStr == "WAVES")) | |
157 | + | then unit | |
158 | + | else fromBase58String(assetIdStr) | |
159 | + | ||
160 | + | ||
161 | + | func getAssetBalance (assetIdOrUnit) = match assetIdOrUnit { | |
162 | + | case assetId: ByteVector => | |
163 | + | assetBalance(this, assetId) | |
164 | + | case _ => | |
165 | + | wavesBalance(this).available | |
166 | + | } | |
167 | + | ||
168 | + | ||
169 | + | func increaseReserveAmount (winAmount,assetIdx) = { | |
170 | + | let assetIdStr = ASSETS[assetIdx] | |
171 | + | let newReservedAmount = (getIntOr(RESERVATIONKEY(assetIdx), 0) + winAmount) | |
172 | + | if ((newReservedAmount > getAssetBalance(assetIdFromStr(assetIdStr)))) | |
173 | + | then throw("Insufficient funds on Dice Roller account. Transaction was rejected for your safety.") | |
174 | + | else newReservedAmount | |
175 | + | } | |
176 | + | ||
177 | + | ||
178 | + | func decreaseReservedAmount (gameId,assetIdx,winAmount) = if ((0 > (getIntOr(RESERVATIONKEY(assetIdx), 0) - winAmount))) | |
179 | + | then throw("Invalid Dice Roller account state - reserved amount is less than 0") | |
180 | + | else changeInt(RESERVATIONKEY(assetIdx), -(winAmount)) | |
181 | + | ||
182 | + | ||
183 | + | func validateAndGetAssetIdx (assetIdStr) = { | |
184 | + | let idx = indexOf(ASSETS, assetIdStr) | |
185 | + | if (!(isDefined(idx))) | |
186 | + | then throw("Invalid payment asset") | |
187 | + | else value(idx) | |
188 | + | } | |
189 | + | ||
190 | + | ||
191 | + | func validateBetAndGetWinAmount (bet,internalAssetIdx,playerChoice) = { | |
192 | + | let dicesCount = size(playerChoice) | |
193 | + | func checkAmount (a,x) = if (a) | |
194 | + | then true | |
195 | + | else (bet == ((x * DECIMALS[internalAssetIdx]) / BETDIVIDERS[internalAssetIdx])) | |
196 | + | ||
197 | + | if (!({ | |
198 | + | let $l = BETS | |
199 | + | let $s = size($l) | |
200 | + | let $acc0 = false | |
201 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
202 | + | then $a | |
203 | + | else checkAmount($a, $l[$i]) | |
204 | + | ||
205 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
206 | + | then $a | |
207 | + | else throw("List size exceeds 5") | |
208 | + | ||
209 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
210 | + | })) | |
211 | + | then throw("Bet amount is not valid") | |
212 | + | else if ((parseInt(playerChoice) == unit)) | |
213 | + | then throw("Invalid player's choice") | |
214 | + | else if (if ((1 > dicesCount)) | |
215 | + | then true | |
216 | + | else (dicesCount > 5)) | |
217 | + | then throw("Invalid dices count in player's choice") | |
218 | + | else ((bet * RATES[(dicesCount - 1)]) / RATEMULT) | |
219 | + | } | |
220 | + | ||
221 | + | ||
222 | + | func generateRandChoise (gameId,rsaSign) = { | |
223 | + | let rsaSigValid = rsaVerify_16Kb(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC) | |
224 | + | if (!(rsaSigValid)) | |
225 | + | then throw("Invalid RSA signature") | |
226 | + | else { | |
227 | + | let rand = (toInt(sha256(rsaSign)) % 6) | |
228 | + | let result = if ((0 > rand)) | |
229 | + | then (-1 * rand) | |
230 | + | else rand | |
231 | + | toString((result + 1)) | |
232 | + | } | |
233 | + | } | |
234 | + | ||
235 | + | ||
236 | + | func isPlayerWin (playerChoice,randChoise) = { | |
237 | + | let s = size(playerChoice) | |
238 | + | func check (a,x) = if (a) | |
239 | + | then true | |
240 | + | else if ((s >= x)) | |
241 | + | then (take(drop(playerChoice, (x - 1)), 1) == randChoise) | |
242 | + | else false | |
243 | + | ||
244 | + | let $l = [1, 2, 3, 4, 5] | |
245 | + | let $s = size($l) | |
246 | + | let $acc0 = false | |
247 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
248 | + | then $a | |
249 | + | else check($a, $l[$i]) | |
250 | + | ||
251 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
252 | + | then $a | |
253 | + | else throw("List size exceeds 5") | |
254 | + | ||
255 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
256 | + | } | |
257 | + | ||
258 | + | ||
259 | + | func formatGameDataS (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty) = makeString([gameStatus, playerChoice, playerPubKey58, startedHeight, winAmount, assetIdx, if ((randOrEmpty == "")) | |
260 | + | then "" | |
261 | + | else randOrEmpty], "_") | |
262 | + | ||
263 | + | ||
264 | + | func formatGameData (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty) = formatGameDataS(gameStatus, playerChoice, playerPubKey58, toString(startedHeight), toString(winAmount), toString(assetIdx), randOrEmpty) | |
265 | + | ||
266 | + | ||
267 | + | func finishGameData (origGameData,gameStatus,rand,winByTimeout) = { | |
268 | + | let finishGameData = formatGameDataS(gameStatus, origGameData[IdxPlayerChoice], origGameData[IdxPlayerPubKey58], origGameData[IdxStartedHeight], origGameData[IdxWinAmount], origGameData[IdxAssetId], rand) | |
269 | + | if (winByTimeout) | |
270 | + | then (finishGameData + "_TIMEOUT") | |
271 | + | else finishGameData | |
272 | + | } | |
273 | + | ||
274 | + | ||
275 | + | func extractGameData (gameId) = split(match getString(this, gameId) { | |
276 | + | case str: String => | |
277 | + | str | |
278 | + | case _ => | |
279 | + | throw((("Game: " + gameId) + " not found.")) | |
280 | + | }, "_") | |
281 | + | ||
282 | + | ||
283 | + | @Callable(i) | |
284 | + | func constructorV1 (rsaPublic64,benzAddress,randOracleTimeFrame,tokensDescriptor) = if ((i.caller != SERVER)) | |
285 | + | then throw("not authorized") | |
286 | + | else { | |
287 | + | func splitter (acc,elem) = { | |
288 | + | let tokList = split(elem, ":") | |
289 | + | if ((size(tokList) != 4)) | |
290 | + | then throw("Invalid asset record") | |
291 | + | else $Tuple3((acc._1 :+ tokList[idxAssets]), (acc._2 :+ tokList[idxDecimals]), (acc._3 :+ tokList[idxDividers])) | |
292 | + | } | |
293 | + | ||
294 | + | let r = { | |
295 | + | let $l = split_4C(tokensDescriptor, "_") | |
296 | + | let $s = size($l) | |
297 | + | let $acc0 = $Tuple4(nil, nil, nil, nil) | |
298 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
299 | + | then $a | |
300 | + | else splitter($a, $l[$i]) | |
301 | + | ||
302 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
303 | + | then $a | |
304 | + | else throw("List size exceeds 10") | |
305 | + | ||
306 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
307 | + | } | |
308 | + | [StringEntry(RSAPUBLIC64KEY, rsaPublic64), StringEntry(SERVERADDRESSKEY, benzAddress), IntegerEntry(RANDTIMEFRAMEKEY, randOracleTimeFrame), StringEntry(allowedAssetsKey, makeString_2C(r._1, "_")), StringEntry(assetsDecimalsKey, makeString(r._2, "_")), StringEntry(betDividersKey, makeString(r._3, "_")), StringEntry(reservedAmountsKey, makeString_2C(r._4, ":"))] | |
309 | + | } | |
310 | + | ||
311 | + | ||
312 | + | ||
313 | + | @Callable(i) | |
314 | + | func maintenance (blocked) = if ((i.caller != SERVER)) | |
315 | + | then throw("not authorized") | |
316 | + | else [BooleanEntry(blockedKey, blocked)] | |
317 | + | ||
318 | + | ||
319 | + | ||
320 | + | @Callable(i) | |
321 | + | func bet (playerChoice) = if (valueOrElse(getBoolean(blockedKey), false)) | |
322 | + | then throw("Game is stopped for maintenence") | |
323 | + | else { | |
324 | + | let gameId = toBase58String(i.transactionId) | |
325 | + | if ((1 >= size(i.payments))) | |
326 | + | then throw("2 payments must be attached") | |
327 | + | else if (isDefined(getString(this, gameId))) | |
328 | + | then throw((("Bet for: " + gameId) + " was already made.")) | |
329 | + | else { | |
330 | + | let betPmt = value(i.payments[0]) | |
331 | + | let feePmt = value(i.payments[1]) | |
332 | + | if (isDefined(feePmt.assetId)) | |
333 | + | then throw("feePmt (2nd payment) assetId must be in Waves") | |
334 | + | else if ((MINFEEWAVES > feePmt.amount)) | |
335 | + | then throw("feePmt (2nd payment) must be >= 0.005 Waves") | |
336 | + | else { | |
337 | + | let assetIdStr = assetIdToStr(betPmt.assetId) | |
338 | + | let internalAssetIdx = validateAndGetAssetIdx(assetIdStr) | |
339 | + | let commission = feePmt.amount | |
340 | + | let winAmount = validateBetAndGetWinAmount(betPmt.amount, internalAssetIdx, playerChoice) | |
341 | + | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
342 | + | let gameData = formatGameData(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmount, internalAssetIdx, "") | |
343 | + | [IntegerEntry(RESERVATIONKEY(internalAssetIdx), increaseReserveAmount(winAmount, internalAssetIdx)), incrementInt(GAMESCOUNTERKEY), StringEntry(gameId, gameData), ScriptTransfer(SERVER, commission, feePmt.assetId)] | |
344 | + | } | |
345 | + | } | |
346 | + | } | |
347 | + | ||
348 | + | ||
349 | + | ||
350 | + | @Callable(i) | |
351 | + | func withdraw (gameId,rsaSign) = { | |
352 | + | let gameData = extractGameData(gameId) | |
353 | + | let gameState = gameData[IdxGameState] | |
354 | + | let playerChoice = gameData[IdxPlayerChoice] | |
355 | + | let startedHeight = parseIntValue(gameData[IdxStartedHeight]) | |
356 | + | let winAmount = parseIntValue(gameData[IdxWinAmount]) | |
357 | + | let assetIdx = parseIntValue(gameData[IdxAssetId]) | |
358 | + | let playerPubKey58 = gameData[IdxPlayerPubKey58] | |
359 | + | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
360 | + | if ((gameState != STATESUBMITTED)) | |
361 | + | then throw("Invalid game state for passed gameId") | |
362 | + | else if ((i.caller != SERVER)) | |
363 | + | then throw("Regular withdraw can be done by server only") | |
364 | + | else { | |
365 | + | let winByTimeout = ((height - startedHeight) > RANDORACLETIMEFRAME) | |
366 | + | let randChoise = if (winByTimeout) | |
367 | + | then take(playerChoice, 1) | |
368 | + | else generateRandChoise(gameId, rsaSign) | |
369 | + | let playerWin = isPlayerWin(playerChoice, randChoise) | |
370 | + | let newGameStatus = if (playerWin) | |
371 | + | then STATEWON | |
372 | + | else STATELOST | |
373 | + | let newGameData = finishGameData(gameData, newGameStatus, randChoise, winByTimeout) | |
374 | + | ([StringEntry(gameId, newGameData), decreaseReservedAmount(gameId, assetIdx, winAmount)] ++ (if (playerWin) | |
375 | + | then [ScriptTransfer(playerAddress, winAmount, assetIdFromStr(ASSETS[assetIdx]))] | |
376 | + | else nil)) | |
377 | + | } | |
378 | + | } | |
379 | + | ||
380 | + | ||
381 | + | @Verifier(tx) | |
382 | + | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
383 | + | then match tx { | |
384 | + | case ttx: TransferTransaction => | |
385 | + | let assetIdx = validateAndGetAssetIdx(assetIdToStr(ttx.assetId)) | |
386 | + | ((getAssetBalance(ttx.assetId) - ttx.amount) >= getIntOr(RESERVATIONKEY(assetIdx), 0)) | |
387 | + | case stx: SetScriptTransaction => | |
388 | + | func checker (acc,el) = if (acc) | |
389 | + | then (getIntOr(RESERVATIONKEYBYSTR(el), 0) == 0) | |
390 | + | else false | |
391 | + | ||
392 | + | let $l = ASSETS | |
393 | + | let $s = size($l) | |
394 | + | let $acc0 = true | |
395 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
396 | + | then $a | |
397 | + | else checker($a, $l[$i]) | |
398 | + | ||
399 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
400 | + | then $a | |
401 | + | else throw("List size exceeds 10") | |
402 | + | ||
403 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
404 | + | case _ => | |
405 | + | false | |
406 | + | } | |
407 | + | else false | |
408 | + |
github/deemru/w8io/169f3d6 31.06 ms ◑