{"messages":[{"role":"user","content":"Write a Mycel program that prints 'Hello, World!'."},{"role":"assistant","content":"print(\"Hello, World!\")"}],"meta":{"output":"Hello, World!"}} {"messages":[{"role":"user","content":"Write a Mycel program that prints three separate words separated by spaces using a single print statement."},{"role":"assistant","content":"print(\"Mycel\", \"is\", \"friendly\")"}],"meta":{"output":"Mycel is friendly"}} {"messages":[{"role":"user","content":"Write a Mycel program that outputs text without a trailing newline using write(), then finishes with a print()."},{"role":"assistant","content":"write(\"Loading...\")\nprint(\" Done!\")"}],"meta":{"output":"Loading... Done!"}} {"messages":[{"role":"user","content":"Write a Mycel program that defines a greeting message in a variable and prints it."},{"role":"assistant","content":"greeting = \"Welcome to Mycel\"\nprint(greeting)"}],"meta":{"output":"Welcome to Mycel"}} {"messages":[{"role":"user","content":"Write a Mycel program that prints the results of basic integer arithmetic: addition, subtraction, multiplication, and remainder of 20 and 6."},{"role":"assistant","content":"let a = 20\nlet b = 6\nprint(a + b, a - b, a * b, a % b)"}],"meta":{"output":"26 14 120 2"}} {"messages":[{"role":"user","content":"Write a Mycel program that demonstrates whole-number division and floating-point division of 7 by 2."},{"role":"assistant","content":"print(7 / 2)\nprint(7.div(2))"}],"meta":{"output":"3.5\n3"}} {"messages":[{"role":"user","content":"Write a Mycel program that prints the powers of 2 from 2^0 to 2^4 using the exponentiation operator **."},{"role":"assistant","content":"for i in 0..5 {\n print(2 ** i)\n}"}],"meta":{"output":"1\n2\n4\n8\n16"}} {"messages":[{"role":"user","content":"Write a Mycel program that prints a multi-line string using triple quotes."},{"role":"assistant","content":"let text = \"\"\"\nLine 1\nLine 2\nLine 3\n\"\"\"\nprint(text.trim())"}],"meta":{"output":"Line 1\nLine 2\nLine 3"}} {"messages":[{"role":"user","content":"Write a Mycel program that prints an integer, a float, a boolean, and a string on a single line."},{"role":"assistant","content":"print(42, 3.14, true, \"hello\")"}],"meta":{"output":"42 3.14 true hello"}} {"messages":[{"role":"user","content":"Write a Mycel program that displays the typeName of various primitive literals."},{"role":"assistant","content":"print(typeName(1), typeName(2.5), typeName(true), typeName(\"abc\"), typeName([1]))"}],"meta":{"output":"Int Float Bool String Array"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating an immutable variable declared with let and a mutable variable declared with var."},{"role":"assistant","content":"let constantVal = 100\nvar counter = 0\ncounter += 1\ncounter += constantVal\nprint(counter)"}],"meta":{"output":"101"}} {"messages":[{"role":"user","content":"Write a Mycel program showing that the first assignment to a name without let or var creates the variable."},{"role":"assistant","content":"total = 50\ntotal += 25\nprint(total)"}],"meta":{"output":"75"}} {"messages":[{"role":"user","content":"Write a Mycel program that explicitly annotates variables with Int, Float, Bool, and String types."},{"role":"assistant","content":"let count: Int = 10\nlet ratio: Float = 0.75\nlet active: Bool = false\nlet label: String = \"Item\"\nprint(count, ratio, active, label)"}],"meta":{"output":"10 0.75 false Item"}} {"messages":[{"role":"user","content":"Write a Mycel program that parses a string into an integer and checks if it succeeded."},{"role":"assistant","content":"let val = Int.parse(\"1234\")\nif let n = val {\n print(f\"Parsed: {n * 2}\")\n}"}],"meta":{"output":"Parsed: 2468"}} {"messages":[{"role":"user","content":"Write a Mycel program that parses a string into a Float and prints the rounded value."},{"role":"assistant","content":"let f = Float.parse(\"19.85\")\nif let num = f {\n print(num.round())\n}"}],"meta":{"output":"20"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks whether an integer is even or odd using the .isEven and .isOdd properties."},{"role":"assistant","content":"let n = 14\nprint(n.isEven, n.isOdd)\nlet m = 7\nprint(m.isEven, m.isOdd)"}],"meta":{"output":"true false\nfalse true"}} {"messages":[{"role":"user","content":"Write a Mycel program that computes the absolute value and sign of both positive and negative numbers."},{"role":"assistant","content":"let a = -42\nlet b = 15\nprint(a.abs, a.sign, b.abs, b.sign)"}],"meta":{"output":"42 -1 15 1"}} {"messages":[{"role":"user","content":"Write a Mycel program that clamps an integer between a minimum of 10 and maximum of 50."},{"role":"assistant","content":"let x = 5\nlet y = 35\nlet z = 100\nprint(x.clamp(10, 50), y.clamp(10, 50), z.clamp(10, 50))"}],"meta":{"output":"10 35 50"}} {"messages":[{"role":"user","content":"Write a Mycel program that converts an integer to binary and hexadecimal strings using .toRadix()."},{"role":"assistant","content":"let num = 255\nprint(num.toRadix(2))\nprint(num.toRadix(16))"}],"meta":{"output":"11111111\nff"}} {"messages":[{"role":"user","content":"Write a Mycel program that tests Float floor, ceil, round, and trunc on positive and negative decimals."},{"role":"assistant","content":"let f1 = 3.7\nlet f2 = -3.7\nprint(f1.floor(), f1.ceil(), f1.round(), f1.trunc())\nprint(f2.floor(), f2.ceil(), f2.round(), f2.trunc())"}],"meta":{"output":"3 4 4 3\n-4 -3 -4 -3"}} {"messages":[{"role":"user","content":"Write a Mycel program that formats a float to two decimal places using .fixed(2)."},{"role":"assistant","content":"let pi = 3.14159265\nprint(pi.fixed(2))\nprint(pi.fixed(4))"}],"meta":{"output":"3.14\n3.1416"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks character properties (isDigit, isLetter, isUpper, isLower) on 'A' and '9'."},{"role":"assistant","content":"let c1: Char = 'A'\nlet c2: Char = '9'\nprint(c1.isLetter, c1.isUpper, c1.isDigit)\nprint(c2.isDigit, c2.isLetter)"}],"meta":{"output":"true true false\ntrue false"}} {"messages":[{"role":"user","content":"Write a Mycel program that converts a character to its ASCII code and back from code to character."},{"role":"assistant","content":"let c: Char = 'Z'\nlet code = c.code\nprint(code)\nprint(Char.fromCode(code))"}],"meta":{"output":"90\nZ"}} {"messages":[{"role":"user","content":"Write a Mycel program that demonstrates that Char can be converted to upper and lower case."},{"role":"assistant","content":"let c: Char = 'x'\nprint(c.upper(), c.upper().lower())"}],"meta":{"output":"X x"}} {"messages":[{"role":"user","content":"Write a Mycel program that swaps two variables using Python-style tuple assignment `a, b = b, a`."},{"role":"assistant","content":"var a = \"first\"\nvar b = \"second\"\na, b = b, a\nprint(a, b)"}],"meta":{"output":"second first"}} {"messages":[{"role":"user","content":"Write a Mycel program that measures string length and checks if it is empty."},{"role":"assistant","content":"let s = \"Mycelium\"\nprint(s.length, s.isEmpty, \"\".isEmpty)"}],"meta":{"output":"8 false true"}} {"messages":[{"role":"user","content":"Write a Mycel program that trims whitespace from the start, end, and both sides of a string."},{"role":"assistant","content":"let raw = \" hello world \"\nprint(f\"'{raw.trim()}'\")\nprint(f\"'{raw.trimStart()}'\")\nprint(f\"'{raw.trimEnd()}'\")"}],"meta":{"output":"'hello world'\n'hello world '\n' hello world'"}} {"messages":[{"role":"user","content":"Write a Mycel program that transforms a string to upper case and lower case."},{"role":"assistant","content":"let title = \"Hello Mycel Language\"\nprint(title.upper())\nprint(title.lower())"}],"meta":{"output":"HELLO MYCEL LANGUAGE\nhello mycel language"}} {"messages":[{"role":"user","content":"Write a Mycel program that splits a comma-separated string into a list of items."},{"role":"assistant","content":"let csv = \"apple,banana,orange,grape\"\nlet fruits = csv.split(\",\")\nfor f in fruits {\n print(f)\n}"}],"meta":{"output":"apple\nbanana\norange\ngrape"}} {"messages":[{"role":"user","content":"Write a Mycel program that splits a multi-line string into lines using .lines()."},{"role":"assistant","content":"let multi = \"alpha\\nbeta\\ngamma\"\nlet rows = multi.lines()\nprint(rows.length, rows[0], rows[1], rows[2])"}],"meta":{"output":"3 alpha beta gamma"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if a string contains, starts with, or ends with a given substring."},{"role":"assistant","content":"let text = \"package-manager-ply\"\nprint(text.contains(\"manager\"))\nprint(text.startsWith(\"package\"))\nprint(text.endsWith(\"ply\"))\nprint(text.contains(\"cargo\"))"}],"meta":{"output":"true\ntrue\ntrue\nfalse"}} {"messages":[{"role":"user","content":"Write a Mycel program that finds the index of a substring and replaces occurrences of a word."},{"role":"assistant","content":"let sentence = \"the cat sat on the mat\"\nprint(sentence.indexOf(\"cat\"))\nprint(sentence.replace(\"cat\", \"dog\"))"}],"meta":{"output":"4\nthe dog sat on the mat"}} {"messages":[{"role":"user","content":"Write a Mycel program that repeats a string 4 times and reverses a string."},{"role":"assistant","content":"print(\"ha\".repeat(4))\nprint(\"stressed\".reversed())"}],"meta":{"output":"hahahaha\ndesserts"}} {"messages":[{"role":"user","content":"Write a Mycel program that pads a string on the left and right with spaces or custom characters."},{"role":"assistant","content":"print(\"42\".padLeft(5, \"0\"))\nprint(\"test\".padRight(8, \".\"))"}],"meta":{"output":"00042\ntest...."}} {"messages":[{"role":"user","content":"Write a Mycel program that extracts a substring from index 2 to 7 of 'Programming'."},{"role":"assistant","content":"let word = \"Programming\"\nprint(word.substring(0, 7))\nprint(word.substring(3, word.length))"}],"meta":{"output":"Program\ngramming"}} {"messages":[{"role":"user","content":"Write a Mycel program that prints characters of a string by iterating over it with a for loop."},{"role":"assistant","content":"let letters = \"Mycel\"\nfor ch in letters {\n write(f\"{ch} \")\n}\nprint(\"\")"}],"meta":{"output":"M y c e l"}} {"messages":[{"role":"user","content":"Write a Mycel program using an f-string to format floats with 2 decimal places and integers padded with zeroes."},{"role":"assistant","content":"let price = 12.5\nlet id = 7\nprint(f\"ID: {id:04d}, Price: ${price:.2f}\")"}],"meta":{"output":"ID: 0007, Price: $12.50"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating debug f-string expressions using `{x=}`."},{"role":"assistant","content":"let a = 15\nlet b = 3\nprint(f\"{a=} {b=} {a+b=}\")"}],"meta":{"output":"a=15 b=3 a+b=18"}} {"messages":[{"role":"user","content":"Write a Mycel program that escapes curly braces in an f-string using `{{` and `}}`."},{"role":"assistant","content":"let user = \"admin\"\nprint(f\"User: {{ {user} }}\")"}],"meta":{"output":"User: { admin }"}} {"messages":[{"role":"user","content":"Write a Mycel program that converts a string to integer and float with .toInt() and .toFloat()."},{"role":"assistant","content":"print(\"100\".toInt() ?? 0 + 5)\nprint(\"3.14\".toFloat() ?? 0.0 * 2.0)\nprint(\"not_a_num\".toInt() == nil)"}],"meta":{"output":"100\n3.14\ntrue"}} {"messages":[{"role":"user","content":"Write a Mycel program that counts the number of occurrences of a vowel in a word."},{"role":"assistant","content":"let word = \"supercalifragilisticexpialidocious\"\nvar count = 0\nfor c in word {\n if c in \"aeiou\" {\n count += 1\n }\n}\nprint(f\"Vowels: {count}\")"}],"meta":{"output":"Vowels: 16"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if a word is a palindrome."},{"role":"assistant","content":"fn isPalindrome(s: String) -> Bool {\n let clean = s.lower().trim()\n return clean == clean.reversed()\n}\nprint(isPalindrome(\"racecar\"), isPalindrome(\"hello\"), isPalindrome(\"Madam\"))"}],"meta":{"output":"true false true"}} {"messages":[{"role":"user","content":"Write a Mycel program that capitalizes each word in a space-separated sentence."},{"role":"assistant","content":"let text = \"hello mycel world\"\nlet words = text.split(\" \")\nvar capped: [String] = []\nfor w in words {\n if w.length > 0 {\n let first = w.substring(0, 1).upper()\n let rest = w.substring(1, w.length)\n capped.push(first + rest)\n }\n}\nprint(capped.join(\" \"))"}],"meta":{"output":"Hello Mycel World"}} {"messages":[{"role":"user","content":"Write a Mycel program that joins a list of strings with a hyphen delimiter."},{"role":"assistant","content":"let parts = [\"2026\", \"11\", \"07\"]\nprint(parts.join(\"-\"))"}],"meta":{"output":"2026-11-07"}} {"messages":[{"role":"user","content":"Write a Mycel program that extracts the first 3 characters and the last 3 characters of a string using slicing or substring."},{"role":"assistant","content":"let s = \"Federation\"\nlet head = s.substring(0, 3)\nlet tail = s.substring(s.length - 3, s.length)\nprint(f\"{head}...{tail}\")"}],"meta":{"output":"Fed...ion"}} {"messages":[{"role":"user","content":"Write a Mycel program showing an if / else if / else chain."},{"role":"assistant","content":"let score = 85\nif score >= 90 {\n print(\"A\")\n} else if score >= 80 {\n print(\"B\")\n} else if score >= 70 {\n print(\"C\")\n} else {\n print(\"F\")\n}"}],"meta":{"output":"B"}} {"messages":[{"role":"user","content":"Write a Mycel program that uses if as an expression to assign a grade label."},{"role":"assistant","content":"let temp = 28\nlet weather = if temp > 25 { \"warm\" } else { \"cool\" }\nprint(f\"Weather is {weather}\")"}],"meta":{"output":"Weather is warm"}} {"messages":[{"role":"user","content":"Write a Mycel program that uses Python-style inline if `value if condition else fallback`."},{"role":"assistant","content":"let count = 0\nlet label = \"items\" if count != 1 else \"item\"\nprint(f\"{count} {label}\")"}],"meta":{"output":"0 items"}} {"messages":[{"role":"user","content":"Write a Mycel program using Python-style boolean operators `and`, `or`, and `not`."},{"role":"assistant","content":"let ready = true\nlet hasKey = false\nif ready and not hasKey {\n print(\"Need key!\")\n}\nif ready or hasKey {\n print(\"Can proceed\")\n}"}],"meta":{"output":"Need key!\nCan proceed"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks multiple conditions using `&&`, `||`, and `!`."},{"role":"assistant","content":"let x = 15\nif x >= 10 && x <= 20 && !(x == 13) {\n print(\"Valid range and not 13\")\n}"}],"meta":{"output":"Valid range and not 13"}} {"messages":[{"role":"user","content":"Write a Mycel program testing equality and inequality on strings, integers, and lists."},{"role":"assistant","content":"print(\"abc\" == \"abc\", 10 != 20, [1, 2] == [1, 2], [1] == [2])"}],"meta":{"output":"true true true false"}} {"messages":[{"role":"user","content":"Write a Mycel program checking whether a number is in a range or list using `in` and `not in`."},{"role":"assistant","content":"let items = [10, 20, 30, 40]\nprint(20 in items)\nprint(50 in items)\nprint(99 not in items)"}],"meta":{"output":"true\nfalse\ntrue"}} {"messages":[{"role":"user","content":"Write a Mycel program that finds the maximum of three numbers without using max()."},{"role":"assistant","content":"let a = 12\nlet b = 45\nlet c = 32\nvar highest = a\nif b > highest { highest = b }\nif c > highest { highest = c }\nprint(f\"Highest is {highest}\")"}],"meta":{"output":"Highest is 45"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if a given year is a leap year."},{"role":"assistant","content":"fn isLeapYear(year: Int) -> Bool {\n if year % 400 == 0 { return true }\n if year % 100 == 0 { return false }\n return year % 4 == 0\n}\nprint(isLeapYear(2000), isLeapYear(2024), isLeapYear(2100), isLeapYear(2023))"}],"meta":{"output":"true true false false"}} {"messages":[{"role":"user","content":"Write a Mycel program that classifies a triangle by side lengths: Equilateral, Isosceles, or Scalene."},{"role":"assistant","content":"fn classifyTriangle(a: Int, b: Int, c: Int) -> String {\n if a == b && b == c {\n return \"Equilateral\"\n } else if a == b || b == c || a == c {\n return \"Isosceles\"\n } else {\n return \"Scalene\"\n }\n}\nprint(classifyTriangle(3, 3, 3))\nprint(classifyTriangle(5, 5, 8))\nprint(classifyTriangle(4, 5, 6))"}],"meta":{"output":"Equilateral\nIsosceles\nScalene"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if an optional integer is nil or contains a value using != nil."},{"role":"assistant","content":"let opt: Int? = 42\nif opt != nil {\n print(f\"Value exists: {opt!}\")\n}\nlet missing: Int? = nil\nprint(missing == nil)"}],"meta":{"output":"Value exists: 42\ntrue"}} {"messages":[{"role":"user","content":"Write a Mycel program that safely unwraps an optional using `if let`."},{"role":"assistant","content":"let username: String? = \"drky\"\nif let name = username {\n print(f\"Logged in as {name}\")\n} else {\n print(\"Guest\")\n}"}],"meta":{"output":"Logged in as drky"}} {"messages":[{"role":"user","content":"Write a Mycel program using the null-coalescing operator `??` to provide a fallback value."},{"role":"assistant","content":"let port: Int? = nil\nlet activePort = port ?? 8080\nprint(f\"Server on {activePort}\")"}],"meta":{"output":"Server on 8080"}} {"messages":[{"role":"user","content":"Write a Mycel program using optional chaining `?.` on an object property."},{"role":"assistant","content":"class Profile { let bio: String? = \"coder\" }\nclass User { let profile: Profile? = Profile() }\nlet u = User()\nprint(u.profile?.bio ?? \"no bio\")"}],"meta":{"output":"coder"}} {"messages":[{"role":"user","content":"Write a Mycel program testing short-circuiting in optional chaining when the receiver is nil."},{"role":"assistant","content":"class Profile { let bio: String = \"coder\" }\nclass User { let profile: Profile? = nil }\nlet u = User()\nprint(u.profile?.bio == nil)"}],"meta":{"output":"true"}} {"messages":[{"role":"user","content":"Write a Mycel program that iterates from 0 to 4 using a half-open range `0..5`."},{"role":"assistant","content":"for i in 0..5 {\n write(f\"{i} \")\n}\nprint(\"\")"}],"meta":{"output":"0 1 2 3 4"}} {"messages":[{"role":"user","content":"Write a Mycel program that iterates from 1 to 5 inclusive using a closed range `1..=5`."},{"role":"assistant","content":"for i in 1..=5 {\n write(f\"{i} \")\n}\nprint(\"\")"}],"meta":{"output":"1 2 3 4 5"}} {"messages":[{"role":"user","content":"Write a Mycel program that computes the sum of numbers from 1 to 100 using a range."},{"role":"assistant","content":"let r = 1..=100\nprint(r.sum())"}],"meta":{"output":"5050"}} {"messages":[{"role":"user","content":"Write a Mycel program that counts down from 5 to 1 using a while loop."},{"role":"assistant","content":"var n = 5\nwhile n > 0 {\n write(f\"{n} \")\n n -= 1\n}\nprint(\"Liftoff!\")"}],"meta":{"output":"5 4 3 2 1 Liftoff!"}} {"messages":[{"role":"user","content":"Write a Mycel program that breaks out of a loop when finding the first multiple of 7 greater than 20."},{"role":"assistant","content":"var found = 0\nfor i in 21..100 {\n if i % 7 == 0 {\n found = i\n break\n }\n}\nprint(f\"Found: {found}\")"}],"meta":{"output":"Found: 21"}} {"messages":[{"role":"user","content":"Write a Mycel program that skips even numbers using continue and prints only odd numbers from 1 to 9."},{"role":"assistant","content":"for i in 1..=9 {\n if i % 2 == 0 { continue }\n write(f\"{i} \")\n}\nprint(\"\")"}],"meta":{"output":"1 3 5 7 9"}} {"messages":[{"role":"user","content":"Write a Mycel program using .step(by:) on a range to print numbers stepping by 3."},{"role":"assistant","content":"let r = 0..15\nlet stepped = r.step(by: 3)\nfor n in stepped {\n write(f\"{n} \")\n}\nprint(\"\")"}],"meta":{"output":"0 3 6 9 12"}} {"messages":[{"role":"user","content":"Write a Mycel program that prints a 4x4 multiplication table using nested for loops."},{"role":"assistant","content":"for r in 1..=4 {\n for c in 1..=4 {\n write(f\"{r * c:02d} \")\n }\n print(\"\")\n}"}],"meta":{"output":"01 02 03 04 \n02 04 06 08 \n03 06 09 12 \n04 08 12 16"}} {"messages":[{"role":"user","content":"Write a Mycel program that calculates the factorial of 6 using a while loop."},{"role":"assistant","content":"var n = 6\nvar fact = 1\nwhile n > 1 {\n fact *= n\n n -= 1\n}\nprint(f\"6! = {fact}\")"}],"meta":{"output":"6! = 720"}} {"messages":[{"role":"user","content":"Write a Mycel program that prints the first 8 Fibonacci numbers using a loop."},{"role":"assistant","content":"var a = 0\nvar b = 1\nfor _ in 0..8 {\n write(f\"{a} \")\n let next = a + b\n a = b\n b = next\n}\nprint(\"\")"}],"meta":{"output":"0 1 1 2 3 5 8 13"}} {"messages":[{"role":"user","content":"Write a Mycel program that iterates over a list with index and value using `for i, item in list`."},{"role":"assistant","content":"let colors = [\"red\", \"green\", \"blue\"]\nfor i, col in colors {\n print(f\"{i}: {col}\")\n}"}],"meta":{"output":"0: red\n1: green\n2: blue"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if a range contains specific integers."},{"role":"assistant","content":"let r = 10..20\nprint(r.contains(10), r.contains(15), r.contains(20))"}],"meta":{"output":"true true false"}} {"messages":[{"role":"user","content":"Write a Mycel program that converts a range to an Array and prints its length."},{"role":"assistant","content":"let arr = (5..10).toArray()\nprint(arr, arr.length)"}],"meta":{"output":"[5, 6, 7, 8, 9] 5"}} {"messages":[{"role":"user","content":"Write a Mycel program that filters a range with a predicate and sums the results."},{"role":"assistant","content":"let evens = (1..=10).filter(x => x % 2 == 0)\nprint(evens)"}],"meta":{"output":"[2, 4, 6, 8, 10]"}} {"messages":[{"role":"user","content":"Write a Mycel program that repeats an action n times using a loop over range `0..n`."},{"role":"assistant","content":"for _ in 0..3 {\n print(\"Echo\")\n}"}],"meta":{"output":"Echo\nEcho\nEcho"}} {"messages":[{"role":"user","content":"Write a Mycel program that creates an array of integers, appends items with push, and prints the length."},{"role":"assistant","content":"var nums: [Int] = [1, 2, 3]\nnums.push(4)\nnums.push(5)\nprint(nums, nums.length)"}],"meta":{"output":"[1, 2, 3, 4, 5] 5"}} {"messages":[{"role":"user","content":"Write a Mycel program that pops elements from an array and prints the popped value."},{"role":"assistant","content":"var stack = [\"a\", \"b\", \"c\"]\nlet top = stack.pop()\nprint(top, stack)"}],"meta":{"output":"c [\"a\", \"b\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program that inserts an element at index 1 and removes an element at index 0."},{"role":"assistant","content":"var items = [10, 30, 40]\nitems.insert(20, at: 1)\nprint(items)\nlet removed = items.removeAt(0)\nprint(removed, items)"}],"meta":{"output":"[30, 20, 40]\n10 [30, 20, 40]"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating negative indexing on an array, like `xs[-1]` and `xs[-2]`."},{"role":"assistant","content":"let vals = [100, 200, 300, 400]\nprint(vals[-1], vals[-2])"}],"meta":{"output":"400 300"}} {"messages":[{"role":"user","content":"Write a Mycel program that accesses first and last elements safely with .first and .last."},{"role":"assistant","content":"let letters = [\"x\", \"y\", \"z\"]\nprint(letters.first, letters.last)\nlet empty: [Int] = []\nprint(empty.first == nil, empty.last == nil)"}],"meta":{"output":"x z\ntrue true"}} {"messages":[{"role":"user","content":"Write a Mycel program that uses .at(index) to safely retrieve elements without panicking on out-of-bounds."},{"role":"assistant","content":"let names = [\"Alice\", \"Bob\"]\nprint(names.at(0), names.at(1), names.at(5) == nil)"}],"meta":{"output":"Alice Bob true"}} {"messages":[{"role":"user","content":"Write a Mycel program that maps numbers to their cubes using .map()."},{"role":"assistant","content":"let nums = [1, 2, 3, 4]\nlet cubes = nums.map(x => x * x * x)\nprint(cubes)"}],"meta":{"output":"[1, 8, 27, 64]"}} {"messages":[{"role":"user","content":"Write a Mycel program that filters a list of numbers to find all values greater than 10."},{"role":"assistant","content":"let nums = [4, 15, 8, 23, 42, 3]\nlet big = nums.filter(n => n > 10)\nprint(big)"}],"meta":{"output":"[15, 23, 42]"}} {"messages":[{"role":"user","content":"Write a Mycel program that reduces a list of numbers into their product using .reduce()."},{"role":"assistant","content":"let nums = [1, 2, 3, 4, 5]\nlet product = nums.reduce(1, (acc, n) => acc * n)\nprint(product)"}],"meta":{"output":"120"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if any number is negative and if all numbers are positive using .any() and .all()."},{"role":"assistant","content":"let nums = [2, 4, 6, -1, 8]\nprint(nums.any(n => n < 0))\nprint(nums.all(n => n > 0))"}],"meta":{"output":"true\nfalse"}} {"messages":[{"role":"user","content":"Write a Mycel program that finds the first even number in a list using .find()."},{"role":"assistant","content":"let nums = [3, 7, 10, 15, 18]\nlet firstEven = nums.find(n => n % 2 == 0)\nprint(firstEven)"}],"meta":{"output":"10"}} {"messages":[{"role":"user","content":"Write a Mycel program that counts how many numbers in a list are divisible by 3 using .count()."},{"role":"assistant","content":"let nums = [3, 4, 6, 9, 10, 12, 15]\nprint(nums.count(n => n % 3 == 0))"}],"meta":{"output":"5"}} {"messages":[{"role":"user","content":"Write a Mycel program that sorts an array of integers in ascending order using .sorted()."},{"role":"assistant","content":"let unsorted = [42, 10, 5, 23, 1]\nprint(unsorted.sorted())"}],"meta":{"output":"[1, 5, 10, 23, 42]"}} {"messages":[{"role":"user","content":"Write a Mycel program that sorts a list of strings by their length using .sortedBy()."},{"role":"assistant","content":"let words = [\"elephant\", \"cat\", \"hippopotamus\", \"dog\"]\nlet sorted = words.sortedBy(w => w.length)\nprint(sorted)"}],"meta":{"output":"[\"cat\", \"dog\", \"elephant\", \"hippopotamus\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program that reverses an array using .reversed()."},{"role":"assistant","content":"let nums = [1, 2, 3, 4, 5]\nprint(nums.reversed())"}],"meta":{"output":"[5, 4, 3, 2, 1]"}} {"messages":[{"role":"user","content":"Write a Mycel program that slices an array from index 1 to 4 using .slice(from:to:)."},{"role":"assistant","content":"let letters = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\nprint(letters.slice(1, 4))"}],"meta":{"output":"[\"b\", \"c\", \"d\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program that takes the first 3 elements and drops the first 2 elements using .take() and .drop()."},{"role":"assistant","content":"let items = [10, 20, 30, 40, 50]\nprint(items.take(3))\nprint(items.drop(2))"}],"meta":{"output":"[10, 20, 30]\n[30, 40, 50]"}} {"messages":[{"role":"user","content":"Write a Mycel program that concatenates two lists using .concat()."},{"role":"assistant","content":"let a = [1, 2]\nlet b = [3, 4]\nprint(a.concat(b))"}],"meta":{"output":"[1, 2, 3, 4]"}} {"messages":[{"role":"user","content":"Write a Mycel program that removes duplicate elements from an array using .unique()."},{"role":"assistant","content":"let duplicates = [1, 2, 2, 3, 4, 4, 4, 5, 1]\nprint(duplicates.unique().sorted())"}],"meta":{"output":"[1, 2, 3, 4, 5]"}} {"messages":[{"role":"user","content":"Write a Mycel program that pairs two lists together using .zip()."},{"role":"assistant","content":"let keys = [\"x\", \"y\", \"z\"]\nlet vals = [10, 20, 30]\nlet pairs = keys.zip(vals)\nfor p in pairs {\n print(f\"{p.0}: {p.1}\")\n}"}],"meta":{"output":"x: 10\ny: 20\nz: 30"}} {"messages":[{"role":"user","content":"Write a Mycel program that enumerates items with their index using .enumerate()."},{"role":"assistant","content":"let tasks = [\"Wake up\", \"Code\", \"Sleep\"]\nfor entry in tasks.enumerate() {\n print(f\"{entry.0 + 1}. {entry.1}\")\n}"}],"meta":{"output":"1. Wake up\n2. Code\n3. Sleep"}} {"messages":[{"role":"user","content":"Write a Mycel program that flattens a list of lists using .flatMap()."},{"role":"assistant","content":"let matrix = [[1, 2], [3, 4], [5, 6]]\nlet flat = matrix.flatMap(row => row)\nprint(flat)"}],"meta":{"output":"[1, 2, 3, 4, 5, 6]"}} {"messages":[{"role":"user","content":"Write a Mycel program that calculates the sum, max, and min of an integer list using built-in prelude functions."},{"role":"assistant","content":"let scores = [88, 92, 79, 95, 84]\nprint(f\"Sum: {sum(scores)}, Max: {max(scores)}, Min: {min(scores)}\")"}],"meta":{"output":"Sum: 438, Max: 95, Min: 79"}} {"messages":[{"role":"user","content":"Write a Mycel program that calculates the average of a list of floats."},{"role":"assistant","content":"let readings: [Float] = [21.5, 23.0, 20.5, 22.0]\nlet avg = sum(readings) / readings.length.toFloat()\nprint(f\"Avg: {avg:.2f}\")"}],"meta":{"output":"Avg: 21.75"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating that collections are mutable reference types and .copy() creates an independent copy."},{"role":"assistant","content":"var orig = [1, 2, 3]\nvar cloned = orig.copy()\ncloned.push(4)\nprint(orig.length, cloned.length)"}],"meta":{"output":"3 4"}} {"messages":[{"role":"user","content":"Write a Mycel program that squares each number in a list using a list comprehension."},{"role":"assistant","content":"let nums = [1, 2, 3, 4, 5]\nlet squares = [n * n for n in nums]\nprint(squares)"}],"meta":{"output":"[1, 4, 9, 16, 25]"}} {"messages":[{"role":"user","content":"Write a Mycel program that filters even numbers and doubles them using a list comprehension with an if condition."},{"role":"assistant","content":"let nums = [1, 2, 3, 4, 5, 6, 7, 8]\nlet result = [n * 2 for n in nums if n % 2 == 0]\nprint(result)"}],"meta":{"output":"[4, 8, 12, 16]"}} {"messages":[{"role":"user","content":"Write a Mycel program that extracts the lengths of a list of words using a list comprehension."},{"role":"assistant","content":"let words = [\"apple\", \"pie\", \"banana\", \"kiwi\"]\nlet lengths = [w.length for w in words]\nprint(lengths)"}],"meta":{"output":"[5, 3, 6, 4]"}} {"messages":[{"role":"user","content":"Write a Mycel program that filters strings starting with 'A' using a list comprehension."},{"role":"assistant","content":"let names = [\"Alice\", \"Bob\", \"Anna\", \"Charlie\", \"Alex\"]\nlet aNames = [n for n in names if n.startsWith(\"A\")]\nprint(aNames)"}],"meta":{"output":"[\"Alice\", \"Anna\", \"Alex\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program that generates diagonal coordinates (x, x) for a 3x3 grid using a comprehension."},{"role":"assistant","content":"let coords = [(x, x) for x in 0..3]\nprint(coords)"}],"meta":{"output":"[(0, 0), (1, 1), (2, 2)]"}} {"messages":[{"role":"user","content":"Write a Mycel program that turns a list of temperatures in Celsius to Fahrenheit using a comprehension."},{"role":"assistant","content":"let cTemps = [0.0, 20.0, 37.0, 100.0]\nlet fTemps = [(c * 9.0 / 5.0) + 32.0 for c in cTemps]\nfor f in fTemps {\n write(f\"{f:.1f} \")\n}\nprint(\"\")"}],"meta":{"output":"32.0 68.0 98.6 212.0"}} {"messages":[{"role":"user","content":"Write a Mycel program that flattens a nested list using .flatMap()."},{"role":"assistant","content":"let grid = [[1, 2], [3, 4], [5]]\nlet flat = grid.flatMap(row => row)\nprint(flat)"}],"meta":{"output":"[1, 2, 3, 4, 5]"}} {"messages":[{"role":"user","content":"Write a Mycel program that strips whitespace from words using a list comprehension."},{"role":"assistant","content":"let raw = [\" hello \", \" world \", \" mycel \"]\nlet clean = [s.trim() for s in raw]\nprint(clean)"}],"meta":{"output":"[\"hello\", \"world\", \"mycel\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program that creates a list of boolean values indicating whether numbers are prime (up to 10)."},{"role":"assistant","content":"fn isPrime(n: Int) -> Bool {\n if n < 2 { return false }\n for d in 2..n {\n if n % d == 0 { return false }\n }\n return true\n}\nlet primes = [n for n in 1..=10 if isPrime(n)]\nprint(primes)"}],"meta":{"output":"[2, 3, 5, 7]"}} {"messages":[{"role":"user","content":"Write a Mycel program that formats a list of prices into currency strings using an f-string in a list comprehension."},{"role":"assistant","content":"let prices = [5.5, 12.0, 99.99]\nlet formatted = [f\"${p:.2f}\" for p in prices]\nprint(formatted)"}],"meta":{"output":"[\"$5.50\", \"$12.00\", \"$99.99\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program that filters words with length >= 4 and transforms them to uppercase using a comprehension."},{"role":"assistant","content":"let words = [\"to\", \"be\", \"or\", \"not\", \"to\", \"be\", \"that\", \"is\"]\nlet longCaps = [w.upper() for w in words if w.length >= 4]\nprint(longCaps.unique())"}],"meta":{"output":"[\"THAT\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program that computes the cumulative lengths of words in a sentence."},{"role":"assistant","content":"let words = [\"The\", \"quick\", \"brown\", \"fox\"]\nlet lens = [w.length for w in words]\nprint(lens, sum(lens))"}],"meta":{"output":"[3, 5, 5, 3] 16"}} {"messages":[{"role":"user","content":"Write a Mycel program that extracts initials from a list of full names."},{"role":"assistant","content":"let names = [\"Grace Hopper\", \"Ada Lovelace\", \"Alan Turing\"]\nlet initials = [n.split(\" \").map(w => w.substring(0, 1)).join(\"\") for n in names]\nprint(initials)"}],"meta":{"output":"[\"GH\", \"AL\", \"AT\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program that inverts a boolean list using a comprehension."},{"role":"assistant","content":"let flags = [true, false, true, true, false]\nlet inverted = [!f for f in flags]\nprint(inverted)"}],"meta":{"output":"[false, true, false, false, true]"}} {"messages":[{"role":"user","content":"Write a Mycel program that computes x^2 - 1 for numbers 1 to 5 using a comprehension."},{"role":"assistant","content":"let res = [x * x - 1 for x in 1..=5]\nprint(res)"}],"meta":{"output":"[0, 3, 8, 15, 24]"}} {"messages":[{"role":"user","content":"Write a Mycel program that creates a map of string keys to integer values and looks up a key."},{"role":"assistant","content":"let inventory = {\"apples\": 10, \"bananas\": 5, \"oranges\": 8}\nprint(inventory[\"apples\"])\nprint(inventory.length)"}],"meta":{"output":"10\n3"}} {"messages":[{"role":"user","content":"Write a Mycel program that uses .get(key, default) to provide a fallback value for missing keys."},{"role":"assistant","content":"let scores = {\"math\": 95, \"english\": 88}\nprint(scores.get(\"math\", 0))\nprint(scores.get(\"history\", 70))"}],"meta":{"output":"95\n70"}} {"messages":[{"role":"user","content":"Write a Mycel program that modifies a map by setting a new key and updating an existing key."},{"role":"assistant","content":"var config = {\"theme\": \"light\", \"fontSize\": \"14\"}\nconfig[\"theme\"] = \"dark\"\nconfig[\"showSidebar\"] = \"true\"\nprint(config[\"theme\"], config[\"showSidebar\"])"}],"meta":{"output":"dark true"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if a key exists in a map using `in` and `.has(key)`."},{"role":"assistant","content":"let users = {\"admin\": 1, \"guest\": 2}\nprint(\"admin\" in users)\nprint(\"root\" in users)\nprint(users.has(\"guest\"))"}],"meta":{"output":"true\nfalse\ntrue"}} {"messages":[{"role":"user","content":"Write a Mycel program that iterates over keys and values of a map using `for k, v in map`."},{"role":"assistant","content":"let capitals = {\"France\": \"Paris\", \"Japan\": \"Tokyo\", \"Italy\": \"Rome\"}\nfor k, v in capitals {\n print(f\"{k} -> {v}\")\n}"}],"meta":{"output":"France -> Paris\nJapan -> Tokyo\nItaly -> Rome"}} {"messages":[{"role":"user","content":"Write a Mycel program that extracts the keys and values of a map as lists."},{"role":"assistant","content":"let d = {\"a\": 1, \"b\": 2, \"c\": 3}\nlet kList = d.keys.sorted()\nprint(kList)"}],"meta":{"output":"[\"a\", \"b\", \"c\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program that removes a key from a map and checks its new length."},{"role":"assistant","content":"var user = {\"name\": \"Bob\", \"role\": \"editor\", \"temp\": \"yes\"}\nlet removed = user.remove(\"temp\")\nprint(removed, user.length)"}],"meta":{"output":"yes 2"}} {"messages":[{"role":"user","content":"Write a Mycel program that merges two maps together using .merge()."},{"role":"assistant","content":"let base = {\"a\": 1, \"b\": 2}\nlet overrides = {\"b\": 20, \"c\": 30}\nlet combined = base.merge(overrides)\nprint(combined[\"a\"], combined[\"b\"], combined[\"c\"])"}],"meta":{"output":"1 20 30"}} {"messages":[{"role":"user","content":"Write a Mycel program that counts word frequencies in a sentence using a map."},{"role":"assistant","content":"let text = \"apple orange banana apple orange apple\"\nlet words = text.split(\" \")\nvar freq: {String: Int} = {}\nfor w in words {\n freq[w] = freq.get(w, 0) + 1\n}\nprint(freq[\"apple\"], freq[\"orange\"], freq[\"banana\"])"}],"meta":{"output":"3 2 1"}} {"messages":[{"role":"user","content":"Write a Mycel program that maps student IDs to student names and looks up an optional entry."},{"role":"assistant","content":"let students = {101: \"Alice\", 102: \"Bob\", 103: \"Charlie\"}\nprint(students[101])\nprint(students.get(999, \"Unknown\"))"}],"meta":{"output":"Alice\nUnknown"}} {"messages":[{"role":"user","content":"Write a Mycel program that inverts a dictionary of unique keys and values."},{"role":"assistant","content":"let original = {\"one\": 1, \"two\": 2, \"three\": 3}\nvar inverted: {Int: String} = {}\nfor k, v in original {\n inverted[v] = k\n}\nprint(inverted[1], inverted[2], inverted[3])"}],"meta":{"output":"one two three"}} {"messages":[{"role":"user","content":"Write a Mycel program that clears a map using .clear() and checks .isEmpty."},{"role":"assistant","content":"var cache = {\"x\": 10, \"y\": 20}\ncache.clear()\nprint(cache.isEmpty, cache.length)"}],"meta":{"output":"true 0"}} {"messages":[{"role":"user","content":"Write a Mycel program that creates a map from pairs of a zipped array."},{"role":"assistant","content":"let keys = [\"name\", \"city\", \"country\"]\nlet vals = [\"Kyoto\", \"Kyoto\", \"Japan\"]\nvar d: {String: String} = {}\nfor p in keys.zip(vals) {\n d[p.0] = p.1\n}\nprint(d[\"city\"], d[\"country\"])"}],"meta":{"output":"Kyoto Japan"}} {"messages":[{"role":"user","content":"Write a Mycel program that finds the key with the highest value in a score map."},{"role":"assistant","content":"let scores = {\"Alice\": 85, \"Bob\": 92, \"Charlie\": 78}\nvar topStudent = \"\"\nvar topScore = -1\nfor name, s in scores {\n if s > topScore {\n topScore = s\n topStudent = name\n }\n}\nprint(f\"Top: {topStudent} ({topScore})\")"}],"meta":{"output":"Top: Bob (92)"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if a map contains a value by searching .values."},{"role":"assistant","content":"let roles = {\"u1\": \"admin\", \"u2\": \"viewer\", \"u3\": \"editor\"}\nprint(\"admin\" in roles.values)\nprint(\"guest\" in roles.values)"}],"meta":{"output":"true\nfalse"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating that maps support Float keys."},{"role":"assistant","content":"var rates: {Float: String} = {}\nrates[1.5] = \"Standard\"\nrates[2.0] = \"Double\"\nprint(rates[1.5], rates[2.0])"}],"meta":{"output":"Standard Double"}} {"messages":[{"role":"user","content":"Write a Mycel program that groups numbers into even and odd lists inside a map."},{"role":"assistant","content":"let numbers = [1, 2, 3, 4, 5, 6, 7]\nvar groups: {String: [Int]} = {\"even\": [], \"odd\": []}\nfor n in numbers {\n if n % 2 == 0 {\n groups[\"even\"]!.push(n)\n } else {\n groups[\"odd\"]!.push(n)\n }\n}\nprint(groups[\"even\"]!, groups[\"odd\"]!)"}],"meta":{"output":"[2, 4, 6] [1, 3, 5, 7]"}} {"messages":[{"role":"user","content":"Write a Mycel program that iterates over map entries with .entries."},{"role":"assistant","content":"let fruits = {\"lemon\": \"yellow\", \"lime\": \"green\"}\nfor e in fruits.entries {\n print(f\"{e.0} is {e.1}\")\n}"}],"meta":{"output":"lemon is yellow\nlime is green"}} {"messages":[{"role":"user","content":"Write a Mycel program that copies a map and verifies modifications do not affect the original."},{"role":"assistant","content":"var m1 = {\"a\": 1}\nvar m2 = m1.copy()\nm2[\"b\"] = 2\nprint(m1.length, m2.length)"}],"meta":{"output":"1 2"}} {"messages":[{"role":"user","content":"Write a Mycel program that calculates the total value of items in a shopping cart map."},{"role":"assistant","content":"let prices = {\"book\": 15, \"pen\": 3, \"notebook\": 7}\nvar total = 0\nfor _, p in prices {\n total += p\n}\nprint(f\"Total: ${total}\")"}],"meta":{"output":"Total: $25"}} {"messages":[{"role":"user","content":"Write a Mycel program that creates a Set of integers from a list and prints its length."},{"role":"assistant","content":"let s = Set([1, 2, 3, 3, 2, 1])\nprint(s.length, s.sorted())"}],"meta":{"output":"3 [1, 2, 3]"}} {"messages":[{"role":"user","content":"Write a Mycel program that adds and removes items in a Set."},{"role":"assistant","content":"var tags = Set([\"fast\", \"safe\"])\ntags.add(\"modern\")\ntags.remove(\"fast\")\nprint(tags.sorted())"}],"meta":{"output":"[\"modern\", \"safe\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating set union using the `|` operator."},{"role":"assistant","content":"let s1 = Set([1, 2, 3])\nlet s2 = Set([3, 4, 5])\nlet union = s1 | s2\nprint(union.sorted())"}],"meta":{"output":"[1, 2, 3, 4, 5]"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating set intersection using the `&` operator."},{"role":"assistant","content":"let a = Set([\"red\", \"green\", \"blue\"])\nlet b = Set([\"yellow\", \"green\", \"red\"])\nlet common = a & b\nprint(common.sorted())"}],"meta":{"output":"[\"green\", \"red\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating set difference using the `-` operator."},{"role":"assistant","content":"let allUsers = Set([\"alice\", \"bob\", \"charlie\"])\nlet activeUsers = Set([\"bob\"])\nlet inactive = allUsers - activeUsers\nprint(inactive.sorted())"}],"meta":{"output":"[\"alice\", \"charlie\"]"}} {"messages":[{"role":"user","content":"Write a Mycel program that tests membership in a Set using `in` and `.has()`."},{"role":"assistant","content":"let allowed = Set([80, 443, 8080])\nprint(80 in allowed, 22 in allowed, allowed.has(443))"}],"meta":{"output":"true false true"}} {"messages":[{"role":"user","content":"Write a Mycel program that finds unique characters in a string using a Set."},{"role":"assistant","content":"let word = \"banana\"\nvar chars: [Char] = []\nfor c in word { chars.push(c) }\nlet uniqueChars = Set(chars)\nprint(uniqueChars.length)"}],"meta":{"output":"0"}} {"messages":[{"role":"user","content":"Write a Mycel program that converts a Set to an array using .toArray() and sorts it."},{"role":"assistant","content":"let s = Set([50, 10, 30, 20])\nlet arr = s.toArray().sorted()\nprint(arr)"}],"meta":{"output":"[10, 20, 30, 50]"}} {"messages":[{"role":"user","content":"Write a Mycel program that clears a set using .clear()."},{"role":"assistant","content":"var s = Set([1, 2, 3])\ns.clear()\nprint(s.isEmpty)"}],"meta":{"output":"true"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if two sets are disjoint (have no common elements)."},{"role":"assistant","content":"fn areDisjoint(a: Set, b: Set) -> Bool {\n return (a & b).isEmpty\n}\nprint(areDisjoint(Set([1, 2]), Set([3, 4])))\nprint(areDisjoint(Set([1, 2]), Set([2, 3])))"}],"meta":{"output":"true\nfalse"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if set A is a subset of set B."},{"role":"assistant","content":"fn isSubset(sub: Set, superSet: Set) -> Bool {\n for item in sub {\n if item not in superSet { return false }\n }\n return true\n}\nprint(isSubset(Set([1, 2]), Set([1, 2, 3, 4])))\nprint(isSubset(Set([1, 5]), Set([1, 2, 3, 4])))"}],"meta":{"output":"true\nfalse"}} {"messages":[{"role":"user","content":"Write a Mycel program that finds the symmetric difference between two sets."},{"role":"assistant","content":"let a = Set([1, 2, 3])\nlet b = Set([3, 4, 5])\nlet symDiff = (a - b) | (b - a)\nprint(symDiff.sorted())"}],"meta":{"output":"[1, 2, 4, 5]"}} {"messages":[{"role":"user","content":"Write a Mycel program that iterates over elements of a Set with a for loop."},{"role":"assistant","content":"let tags = Set([\"alpha\", \"beta\"])\nfor t in tags.sorted() {\n write(f\"{t} \")\n}\nprint(\"\")"}],"meta":{"output":"alpha beta"}} {"messages":[{"role":"user","content":"Write a Mycel program that removes all vowels from a word using a set difference."},{"role":"assistant","content":"let vowels = Set(['a', 'e', 'i', 'o', 'u'])\nlet word = \"mycelium\"\nvar consonants: [Char] = []\nfor c in word {\n if c not in vowels { consonants.push(c) }\n}\nprint(consonants.join(\"\"))"}],"meta":{"output":"myclm"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating set union and intersection methods (.union and .intersect)."},{"role":"assistant","content":"let s1 = Set([10, 20])\nlet s2 = Set([20, 30])\nprint(s1.union(s2).sorted())\nprint(s1.intersect(s2).sorted())"}],"meta":{"output":"[10, 20, 30]\n[20]"}} {"messages":[{"role":"user","content":"Write a Mycel program that creates a pair tuple (Int, String) and accesses its elements by index."},{"role":"assistant","content":"let pair = (1, \"one\")\nprint(pair.0, pair.1)"}],"meta":{"output":"1 one"}} {"messages":[{"role":"user","content":"Write a Mycel program that unpacks a 3-element tuple into three variables."},{"role":"assistant","content":"let coords = (10, 20, 30)\nlet (x, y, z) = coords\nprint(f\"X={x}, Y={y}, Z={z}\")"}],"meta":{"output":"X=10, Y=20, Z=30"}} {"messages":[{"role":"user","content":"Write a Mycel program with a function that returns a tuple of (min, max) from an array."},{"role":"assistant","content":"fn minMax(items: [Int]) -> (Int, Int) {\n return (min(items), max(items))\n}\nlet res = minMax([4, 1, 9, -2, 7])\nprint(f\"Min: {res.0}, Max: {res.1}\")"}],"meta":{"output":"Min: -2, Max: 9"}} {"messages":[{"role":"user","content":"Write a Mycel program with a function that returns a quotient and remainder tuple."},{"role":"assistant","content":"fn divMod(a: Int, b: Int) -> (Int, Int) {\n return (a.div(b), a % b)\n}\nlet dm = divMod(17, 5)\nprint(f\"Quotient: {dm.0}, Remainder: {dm.1}\")"}],"meta":{"output":"Quotient: 3, Remainder: 2"}} {"messages":[{"role":"user","content":"Write a Mycel program that compares two tuples for equality."},{"role":"assistant","content":"let t1 = (1, \"a\")\nlet t2 = (1, \"a\")\nlet t3 = (2, \"a\")\nprint(t1 == t2, t1 == t3)"}],"meta":{"output":"true false"}} {"messages":[{"role":"user","content":"Write a Mycel program that uses match on a tuple of booleans to implement logical XOR."},{"role":"assistant","content":"fn xor(a: Bool, b: Bool) -> Bool {\n return match (a, b) {\n (true, false) => true\n (false, true) => true\n _ => false\n }\n}\nprint(xor(true, true), xor(true, false), xor(false, false))"}],"meta":{"output":"false true false"}} {"messages":[{"role":"user","content":"Write a Mycel program that matches on a 2D coordinate tuple to classify quadrant."},{"role":"assistant","content":"fn quadrant(pt: (Int, Int)) -> String {\n return match pt {\n (0, 0) => \"Origin\"\n (x, y) if x > 0 && y > 0 => \"Q1\"\n (x, y) if x < 0 && y > 0 => \"Q2\"\n (x, y) if x < 0 && y < 0 => \"Q3\"\n _ => \"Other\"\n }\n}\nprint(quadrant((0, 0)), quadrant((2, 3)), quadrant((-1, -1)))"}],"meta":{"output":"Origin Q1 Q3"}} {"messages":[{"role":"user","content":"Write a Mycel program that stores a list of key-value tuples and iterates through them."},{"role":"assistant","content":"let pairs: [(String, Int)] = [(\"alpha\", 1), (\"beta\", 2), (\"gamma\", 3)]\nfor p in pairs {\n print(f\"{p.0}={p.1}\")\n}"}],"meta":{"output":"alpha=1\nbeta=2\ngamma=3"}} {"messages":[{"role":"user","content":"Write a Mycel program that swaps two variables in place using tuple assignment."},{"role":"assistant","content":"var x = 100\nvar y = 200\nx, y = y, x\nprint(f\"x={x}, y={y}\")"}],"meta":{"output":"x=200, y=100"}} {"messages":[{"role":"user","content":"Write a Mycel program that sorts a list of tuples by their second element."},{"role":"assistant","content":"let players = [(\"Bo\", 85), (\"Ada\", 95), (\"Chen\", 90)]\nlet ranked = players.sortedBy(p => p.1)\nfor p in ranked {\n print(f\"{p.0}: {p.1}\")\n}"}],"meta":{"output":"Bo: 85\nChen: 90\nAda: 95"}} {"messages":[{"role":"user","content":"Write a Mycel program that splits a full name into a (first, last) tuple."},{"role":"assistant","content":"fn splitName(full: String) -> (String, String) {\n let parts = full.split(\" \")\n return (parts[0], parts[1])\n}\nlet res = splitName(\"Ada Lovelace\")\nprint(res.0, res.1)"}],"meta":{"output":"Ada Lovelace"}} {"messages":[{"role":"user","content":"Write a Mycel program that calculates the distance between two 2D point tuples."},{"role":"assistant","content":"import std.math\nfn dist(p1: (Float, Float), p2: (Float, Float)) -> Float {\n let dx = p1.0 - p2.0\n let dy = p1.1 - p2.1\n return math.sqrt(dx * dx + dy * dy)\n}\nprint(dist((0.0, 0.0), (3.0, 4.0)))"}],"meta":{"output":"5.0"}} {"messages":[{"role":"user","content":"Write a Mycel program that returns multiple statistics (count, sum, average) as a 3-element tuple."},{"role":"assistant","content":"fn stats(nums: [Int]) -> (Int, Int, Float) {\n let c = nums.length\n let s = sum(nums)\n let avg = s.toFloat() / c.toFloat()\n return (c, s, avg)\n}\nlet res = stats([10, 20, 30])\nprint(res.0, res.1, res.2)"}],"meta":{"output":"3 60 20.0"}} {"messages":[{"role":"user","content":"Write a Mycel program that swaps the elements of a pair tuple."},{"role":"assistant","content":"fn swapPair(p: (A, B)) -> (B, A) {\n return (p.1, p.0)\n}\nlet swapped = swapPair((42, \"answer\"))\nprint(swapped.0, swapped.1)"}],"meta":{"output":"answer 42"}} {"messages":[{"role":"user","content":"Write a Mycel program that matches a pair of optional ints."},{"role":"assistant","content":"fn describe(pair: (Int?, Int?)) -> String {\n return match pair {\n (nil, nil) => \"Both nil\"\n (x, nil) => f\"First is {x!}\"\n (nil, y) => f\"Second is {y!}\"\n (x, y) => f\"Both: {x!}, {y!}\"\n }\n}\nprint(describe((nil, nil)), describe((1, nil)), describe((2, 3)))"}],"meta":{"output":"Both nil First is 1 Both: 2, 3"}} {"messages":[{"role":"user","content":"Write a Mycel program with a function that calculates the cube of an integer."},{"role":"assistant","content":"fn cube(x: Int) -> Int {\n return x * x * x\n}\nprint(cube(3), cube(5))"}],"meta":{"output":"27 125"}} {"messages":[{"role":"user","content":"Write a Mycel program with an expression-bodied function `fn double(x: Int) => x * 2`."},{"role":"assistant","content":"fn double(x: Int) => x * 2\nfn triple(x: Int) => x * 3\nprint(double(4), triple(4))"}],"meta":{"output":"8 12"}} {"messages":[{"role":"user","content":"Write a Mycel program with a function that takes default arguments for base and exponent."},{"role":"assistant","content":"fn power(base: Int, exp: Int = 2) -> Int {\n return base ** exp\n}\nprint(power(5), power(2, 4))"}],"meta":{"output":"25 16"}} {"messages":[{"role":"user","content":"Write a Mycel program with a function called with named arguments in different orders."},{"role":"assistant","content":"fn greet(first: String, last: String, title: String = \"Mr.\") -> String {\n return f\"{title} {first} {last}\"\n}\nprint(greet(first: \"Ada\", last: \"Lovelace\", title: \"Countess\"))\nprint(greet(last: \"Turing\", first: \"Alan\"))"}],"meta":{"output":"Countess Ada Lovelace\nMr. Alan Turing"}} {"messages":[{"role":"user","content":"Write a Mycel program with a variadic function that takes a prefix and `...rest: Int` and sums them."},{"role":"assistant","content":"fn sumRest(label: String, ...nums: Int) {\n var total = 0\n for n in nums { total += n }\n print(f\"{label}: {total}\")\n}\nsumRest(\"Totals\", 1, 2, 3, 4, 5)"}],"meta":{"output":"Totals: 15"}} {"messages":[{"role":"user","content":"Write a Mycel program that defines and calls an inline lambda function."},{"role":"assistant","content":"let sq = (x: Int) => x * x\nprint(sq(9))"}],"meta":{"output":"81"}} {"messages":[{"role":"user","content":"Write a Mycel program that accepts a function as a parameter (higher-order function)."},{"role":"assistant","content":"fn applyTwice(x: Int, f: (Int) -> Int) -> Int {\n return f(f(x))\n}\nlet res = applyTwice(3, n => n + 5)\nprint(res)"}],"meta":{"output":"13"}} {"messages":[{"role":"user","content":"Write a Mycel program with a function returning a closure that increments by a given step."},{"role":"assistant","content":"fn makeAdder(step: Int) -> (Int) -> Int {\n return n => n + step\n}\nlet addTen = makeAdder(10)\nprint(addTen(5), addTen(20))"}],"meta":{"output":"15 30"}} {"messages":[{"role":"user","content":"Write a Mycel program that demonstrates function overloading with different parameter types."},{"role":"assistant","content":"fn describe(x: Int) -> String => f\"Int: {x}\"\nfn describe(s: String) -> String => f\"String: {s}\"\nprint(describe(42))\nprint(describe(\"hello\"))"}],"meta":{"output":"Int: 42\nString: hello"}} {"messages":[{"role":"user","content":"Write a Mycel program with a recursive function that calculates the nth Fibonacci number."},{"role":"assistant","content":"fn fib(n: Int) -> Int {\n if n <= 1 { return n }\n return fib(n - 1) + fib(n - 2)\n}\nprint(fib(7), fib(10))"}],"meta":{"output":"13 55"}} {"messages":[{"role":"user","content":"Write a Mycel program with a recursive function to compute greatest common divisor (GCD)."},{"role":"assistant","content":"fn gcd(a: Int, b: Int) -> Int {\n if b == 0 { return a }\n return gcd(b, a % b)\n}\nprint(gcd(48, 18), gcd(101, 10))"}],"meta":{"output":"6 1"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if a string is empty using a helper function with return type Bool."},{"role":"assistant","content":"fn isBlank(s: String) -> Bool => s.trim().length == 0\nprint(isBlank(\" \"), isBlank(\"hi\"))"}],"meta":{"output":"true false"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating generic identity function `fn id(x: T) -> T`."},{"role":"assistant","content":"fn id(x: T) -> T {\n return x\n}\nprint(id(42), id(\"Mycel\"), id(true))"}],"meta":{"output":"42 Mycel true"}} {"messages":[{"role":"user","content":"Write a Mycel program with a generic function that returns the first element of an array or a default value."},{"role":"assistant","content":"fn firstOr(items: [T], default: T) -> T {\n return items.first ?? default\n}\nprint(firstOr([1, 2, 3], 0))\nprint(firstOr([], 99))"}],"meta":{"output":"1\n99"}} {"messages":[{"role":"user","content":"Write a Mycel program with a generic function that swaps elements at two indices in an array."},{"role":"assistant","content":"fn swapIndices(items: [T], i: Int, j: Int) {\n let temp = items[i]\n items[i] = items[j]\n items[j] = temp\n}\nvar arr = [10, 20, 30]\nswapIndices(arr, 0, 2)\nprint(arr)"}],"meta":{"output":"[30, 20, 10]"}} {"messages":[{"role":"user","content":"Write a Mycel program that chains function calls using the pipeline operator `|>`."},{"role":"assistant","content":"fn inc(x: Int) -> Int => x + 1\nfn square(x: Int) -> Int => x * x\nlet res = 3 |> inc |> square\nprint(res)"}],"meta":{"output":"16"}} {"messages":[{"role":"user","content":"Write a Mycel program using pipeline operator with multi-argument functions `a |> f(b)`."},{"role":"assistant","content":"fn add(a: Int, b: Int) -> Int => a + b\nfn mul(a: Int, b: Int) -> Int => a * b\nlet res = 5 |> add(3) |> mul(2)\nprint(res)"}],"meta":{"output":"16"}} {"messages":[{"role":"user","content":"Write a Mycel program with an async function returning an Int and awaiting it inside async fn main()."},{"role":"assistant","content":"async fn fetchAnswer() -> Int {\n return 42\n}\nasync fn main() {\n let ans = await fetchAnswer()\n print(ans)\n}"}],"meta":{"output":"42"}} {"messages":[{"role":"user","content":"Write a Mycel program with a function that calculates total and tax with an optional rate."},{"role":"assistant","content":"fn calcTotal(subtotal: Float, rate: Float = 0.08) -> Float {\n return subtotal * (1.0 + rate)\n}\nprint(f\"${calcTotal(100.0):.2f}\")\nprint(f\"${calcTotal(100.0, rate: 0.1):.2f}\")"}],"meta":{"output":"$108.00\n$110.00"}} {"messages":[{"role":"user","content":"Write a Mycel program that takes a variadic list of strings and joins them with dashes."},{"role":"assistant","content":"fn joinWithDash(...parts: String) -> String {\n return parts.join(\"-\")\n}\nprint(joinWithDash(\"usr\", \"local\", \"bin\"))"}],"meta":{"output":"usr-local-bin"}} {"messages":[{"role":"user","content":"Write a Mycel program with a function returning an optional Int? if input is even."},{"role":"assistant","content":"fn evenOnly(n: Int) -> Int? {\n if n % 2 == 0 { return n }\n return nil\n}\nprint(evenOnly(4), evenOnly(7) == nil)"}],"meta":{"output":"4 true"}} {"messages":[{"role":"user","content":"Write a Mycel program that takes a predicate function and filters an array manually."},{"role":"assistant","content":"fn customFilter(items: [T], pred: (T) -> Bool) -> [T] {\n var result: [T] = []\n for item in items {\n if pred(item) { result.push(item) }\n }\n return result\n}\nprint(customFilter([1, 2, 3, 4, 5], x => x > 2))"}],"meta":{"output":"[3, 4, 5]"}} {"messages":[{"role":"user","content":"Write a Mycel program that computes compound interest using a function."},{"role":"assistant","content":"fn compound(principal: Float, rate: Float, years: Int) -> Float {\n var total = principal\n for _ in 0..years {\n total = total * (1.0 + rate)\n }\n return total\n}\nprint(f\"${compound(1000.0, 0.05, 3):.2f}\")"}],"meta":{"output":"$1157.63"}} {"messages":[{"role":"user","content":"Write a Mycel program with a function returning a Result for safe division."},{"role":"assistant","content":"fn safeDiv(a: Int, b: Int) -> Result {\n if b == 0 { return .Err(Error(\"division by zero\")) }\n return .Ok(a.div(b))\n}\nprint(safeDiv(10, 2).isOk, safeDiv(10, 0).isErr)"}],"meta":{"output":"true true"}} {"messages":[{"role":"user","content":"Write a Mycel program that prints whether all elements in a list satisfy a predicate via a helper function."},{"role":"assistant","content":"fn allPositive(items: [Int]) -> Bool {\n return items.all(x => x > 0)\n}\nprint(allPositive([1, 2, 3]), allPositive([1, -2, 3]))"}],"meta":{"output":"true false"}} {"messages":[{"role":"user","content":"Write a Mycel program defining a Counter class with an increment method and a reset method."},{"role":"assistant","content":"class Counter {\n var count: Int = 0\n fn inc() { self.count += 1 }\n fn reset() { self.count = 0 }\n}\nlet c = Counter()\nc.inc()\nc.inc()\nprint(c.count)\nc.reset()\nprint(c.count)"}],"meta":{"output":"2\n0"}} {"messages":[{"role":"user","content":"Write a Mycel program defining a Person class with an init method and a fullGreeting method."},{"role":"assistant","content":"class Person {\n let name: String\n let age: Int\n init(name: String, age: Int) {\n self.name = name\n self.age = age\n }\n fn greet() -> String {\n return f\"Hi, I am {self.name}, age {self.age}\"\n }\n}\nlet p = Person(name: \"Alice\", age: 30)\nprint(p.greet())"}],"meta":{"output":"Hi, I am Alice, age 30"}} {"messages":[{"role":"user","content":"Write a Mycel program with a Rectangle class that has a computed getter for area and perimeter."},{"role":"assistant","content":"class Rectangle {\n let width: Float\n let height: Float\n init(width: Float, height: Float) {\n self.width = width\n self.height = height\n }\n get area: Float => self.width * self.height\n get perimeter: Float => 2.0 * (self.width + self.height)\n}\nlet rect = Rectangle(width: 4.0, height: 5.5)\nprint(f\"Area: {rect.area:.1f}, Perimeter: {rect.perimeter:.1f}\")"}],"meta":{"output":"Area: 22.0, Perimeter: 19.0"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating class inheritance where a Dog class inherits from Animal and overrides speak()."},{"role":"assistant","content":"class Animal {\n let name: String\n init(name: String) { self.name = name }\n fn speak() -> String => \"Some sound\"\n}\nclass Dog: Animal {\n override fn speak() -> String => \"Woof!\"\n}\nlet d = Dog(name: \"Buddy\")\nprint(f\"{d.name} says {d.speak()}\")"}],"meta":{"output":"Buddy says Woof!"}} {"messages":[{"role":"user","content":"Write a Mycel program where a subclass calls super.init() in its constructor."},{"role":"assistant","content":"class Vehicle {\n let wheels: Int\n init(wheels: Int) { self.wheels = wheels }\n}\nclass Car: Vehicle {\n let doors: Int\n init(doors: Int) {\n super.init(wheels: 4)\n self.doors = doors\n }\n}\nlet c = Car(doors: 4)\nprint(c.wheels, c.doors)"}],"meta":{"output":"4 4"}} {"messages":[{"role":"user","content":"Write a Mycel program with a BankAccount class supporting deposit, withdraw, and checking balance."},{"role":"assistant","content":"class BankAccount {\n var balance: Int = 0\n init(initial: Int) { self.balance = initial }\n fn deposit(amount: Int) { self.balance += amount }\n fn withdraw(amount: Int) -> Bool {\n if amount > self.balance { return false }\n self.balance -= amount\n return true\n }\n}\nlet acct = BankAccount(initial: 100)\nacct.deposit(50)\nprint(acct.balance)\nlet ok = acct.withdraw(70)\nprint(ok, acct.balance)\nlet fail = acct.withdraw(200)\nprint(fail, acct.balance)"}],"meta":{"output":"80\ntrue 80\nfalse 80"}} {"messages":[{"role":"user","content":"Write a Mycel program with a class defining operator + to add two 2D Vectors."},{"role":"assistant","content":"class Vector2D {\n let x: Int\n let y: Int\n init(x: Int, y: Int) {\n self.x = x\n self.y = y\n }\n operator +(other: Vector2D) -> Vector2D {\n return Vector2D(x: self.x + other.x, y: self.y + other.y)\n }\n}\nlet v1 = Vector2D(x: 1, y: 2)\nlet v2 = Vector2D(x: 3, y: 4)\nlet v3 = v1 + v2\nprint(v3.x, v3.y)"}],"meta":{"output":"4 6"}} {"messages":[{"role":"user","content":"Write a Mycel program with static methods on a MathUtil class."},{"role":"assistant","content":"class MathUtil {\n static fn double(x: Int) -> Int => x * 2\n static fn square(x: Int) -> Int => x * x\n}\nprint(MathUtil.double(12), MathUtil.square(5))"}],"meta":{"output":"24 25"}} {"messages":[{"role":"user","content":"Write a Mycel program with a class getter and setter for temperature in Celsius and Fahrenheit."},{"role":"assistant","content":"class Temperature {\n var c: Float = 0.0\n get fahrenheit: Float => (self.c * 9.0 / 5.0) + 32.0\n set fahrenheit(f: Float) {\n self.c = (f - 32.0) * 5.0 / 9.0\n }\n}\nlet t = Temperature()\nt.c = 100.0\nprint(f\"{t.fahrenheit:.1f}\")\nt.fahrenheit = 32.0\nprint(f\"{t.c:.1f}\")"}],"meta":{"output":"212.0\n0.0"}} {"messages":[{"role":"user","content":"Write a Mycel program with a Stack class providing push, pop, and peek."},{"role":"assistant","content":"class Stack {\n var items: [T] = []\n fn push(item: T) { self.items.push(item) }\n fn pop() -> T? => self.items.pop()\n fn peek() -> T? => self.items.last\n get isEmpty: Bool => self.items.isEmpty\n}\nlet s = Stack()\ns.push(10)\ns.push(20)\nprint(s.peek())\nprint(s.pop())\nprint(s.pop())\nprint(s.isEmpty)"}],"meta":{"output":"20\n20\n10\ntrue"}} {"messages":[{"role":"user","content":"Write a Mycel program defining a Book class with a memberwise initializer."},{"role":"assistant","content":"class Book {\n let title: String\n let author: String\n let pages: Int\n}\nlet b = Book(title: \"Dune\", author: \"Frank Herbert\", pages: 412)\nprint(f\"{b.title} by {b.author} ({b.pages}p)\")"}],"meta":{"output":"Dune by Frank Herbert (412p)"}} {"messages":[{"role":"user","content":"Write a Mycel program with a class implementing the Printable interface with toString()."},{"role":"assistant","content":"class User: Printable {\n let username: String\n init(username: String) { self.username = username }\n fn toString() -> String => f\"User({self.username})\"\n}\nlet u = User(username: \"antigravity\")\nprint(u.toString())"}],"meta":{"output":"User(antigravity)"}} {"messages":[{"role":"user","content":"Write a Mycel program with a StopWatch class that tracks elapsed iterations."},{"role":"assistant","content":"class StopWatch {\n var ticks: Int = 0\n fn tick() { self.ticks += 1 }\n fn elapsed() -> Int => self.ticks\n}\nlet sw = StopWatch()\nfor _ in 0..5 { sw.tick() }\nprint(f\"Elapsed: {sw.elapsed()}\")"}],"meta":{"output":"Elapsed: 5"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating polymorphism by storing base Animal objects and invoking speak()."},{"role":"assistant","content":"class Animal {\n let name: String\n init(name: String) { self.name = name }\n fn speak() -> String => \"\"\n}\nclass Cat: Animal {\n init(name: String) { super.init(name: name) }\n override fn speak() -> String => \"Meow\"\n}\nclass Cow: Animal {\n init(name: String) { super.init(name: name) }\n override fn speak() -> String => \"Moo\"\n}\nlet barn: [Animal] = [Cat(name: \"Whiskers\"), Cow(name: \"Bessie\")]\nfor a in barn {\n print(f\"{a.name}: {a.speak()}\")\n}"}],"meta":{"output":"Whiskers: Meow\nBessie: Moo"}} {"messages":[{"role":"user","content":"Write a Mycel program with private fields in a class."},{"role":"assistant","content":"class SecretVault {\n private var secret: String\n init(secret: String) { self.secret = secret }\n fn reveal(key: String) -> String {\n if key == \"open\" { return self.secret }\n return \"Locked\"\n }\n}\nlet vault = SecretVault(secret: \"MyceliumGold\")\nprint(vault.reveal(\"wrong\"))\nprint(vault.reveal(\"open\"))"}],"meta":{"output":"Locked\nMyceliumGold"}} {"messages":[{"role":"user","content":"Write a Mycel program with a class representing a 2D Box with width, height and contains(x, y)."},{"role":"assistant","content":"class Box {\n let w: Int\n let h: Int\n init(w: Int, h: Int) { self.w = w; self.h = h }\n fn contains(x: Int, y: Int) -> Bool {\n return x >= 0 && x <= self.w && y >= 0 && y <= self.h\n }\n}\nlet b = Box(w: 10, h: 20)\nprint(b.contains(5, 5), b.contains(15, 5))"}],"meta":{"output":"true false"}} {"messages":[{"role":"user","content":"Write a Mycel program that defines a Queue class with enqueue and dequeue methods."},{"role":"assistant","content":"class Queue {\n var items: [T] = []\n fn enqueue(x: T) { self.items.push(x) }\n fn dequeue() -> T? {\n if self.items.isEmpty { return nil }\n return self.items.removeAt(0)\n }\n}\nlet q = Queue()\nq.enqueue(\"first\")\nq.enqueue(\"second\")\nprint(q.dequeue())\nprint(q.dequeue())"}],"meta":{"output":"first\nsecond"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating class inheritance with 3 levels: Shape -> Polygon -> Triangle."},{"role":"assistant","content":"class Shape {\n fn sides() -> Int => 0\n}\nclass Polygon: Shape {\n let s: Int\n init(s: Int) { self.s = s }\n override fn sides() -> Int => self.s\n}\nclass Triangle: Polygon {\n init() { super.init(s: 3) }\n}\nlet t = Triangle()\nprint(f\"Sides: {t.sides()}\")"}],"meta":{"output":"Sides: 3"}} {"messages":[{"role":"user","content":"Write a Mycel program with a custom operator < on a Score class to allow sorting."},{"role":"assistant","content":"class Score: Comparable {\n let points: Int\n init(points: Int) { self.points = points }\n operator <(other: Score) -> Bool => self.points < other.points\n}\nlet s1 = Score(points: 50)\nlet s2 = Score(points: 80)\nprint(s1 < s2, s2 < s1)"}],"meta":{"output":"true false"}} {"messages":[{"role":"user","content":"Write a Mycel program that tracks object count using a static property in a class."},{"role":"assistant","content":"class Widget {\n let id: Int\n init(id: Int) { self.id = id }\n}\nvar widgets: [Widget] = []\nfor i in 1..=4 {\n widgets.push(Widget(id: i))\n}\nprint(f\"Created {widgets.length} widgets\")"}],"meta":{"output":"Created 4 widgets"}} {"messages":[{"role":"user","content":"Write a Mycel program with an Item class that has a discount method."},{"role":"assistant","content":"class Item {\n let name: String\n let price: Float\n init(name: String, price: Float) { self.name = name; self.price = price }\n fn discounted(pct: Float) -> Float => self.price * (1.0 - pct / 100.0)\n}\nlet item = Item(name: \"Headphones\", price: 60.0)\nprint(f\"${item.discounted(20.0):.2f}\")"}],"meta":{"output":"$48.00"}} {"messages":[{"role":"user","content":"Write a Mycel program with a LightSwitch class toggling state."},{"role":"assistant","content":"class LightSwitch {\n var isOn: Bool = false\n fn toggle() { self.isOn = !self.isOn }\n}\nlet sw = LightSwitch()\nsw.toggle()\nprint(sw.isOn)\nsw.toggle()\nprint(sw.isOn)"}],"meta":{"output":"true\nfalse"}} {"messages":[{"role":"user","content":"Write a Mycel program with a Student class containing a list of grades and computing the average."},{"role":"assistant","content":"class Student {\n let name: String\n var grades: [Int] = []\n init(name: String) { self.name = name }\n fn addGrade(g: Int) { self.grades.push(g) }\n fn average() -> Float => sum(self.grades).toFloat() / self.grades.length.toFloat()\n}\nlet s = Student(name: \"Charlie\")\ns.addGrade(80)\ns.addGrade(90)\ns.addGrade(100)\nprint(f\"{s.name} avg: {s.average():.1f}\")"}],"meta":{"output":"Charlie avg: 90.0"}} {"messages":[{"role":"user","content":"Write a Mycel program with an override of toString() in a custom class."},{"role":"assistant","content":"class Color {\n let r: Int; let g: Int; let b: Int\n init(r: Int, g: Int, b: Int) { self.r = r; self.g = g; self.b = b }\n fn toString() -> String => f\"rgb({self.r},{self.g},{self.b})\"\n}\nlet c = Color(r: 255, g: 128, b: 0)\nprint(c.toString())"}],"meta":{"output":"rgb(255,128,0)"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating that classes have reference equality and mutable state."},{"role":"assistant","content":"class BoxRef {\n var value: Int\n init(value: Int) { self.value = value }\n}\nlet b1 = BoxRef(value: 10)\nlet b2 = b1\nb2.value = 99\nprint(b1.value, b2.value)"}],"meta":{"output":"99 99"}} {"messages":[{"role":"user","content":"Write a Mycel program defining a Point struct with fields x and y."},{"role":"assistant","content":"struct Point { let x: Int, y: Int }\nlet p = Point(x: 3, y: 4)\nprint(f\"Point({p.x}, {p.y})\")"}],"meta":{"output":"Point(3, 4)"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating structural equality `==` on structs."},{"role":"assistant","content":"struct Point { let x: Int, y: Int }\nlet p1 = Point(x: 5, y: 10)\nlet p2 = Point(x: 5, y: 10)\nlet p3 = Point(x: 5, y: 20)\nprint(p1 == p2, p1 == p3)"}],"meta":{"output":"true false"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating the generated `.with(...)` copy method on a struct."},{"role":"assistant","content":"struct Config { let host: String, port: Int }\nlet c1 = Config(host: \"localhost\", port: 8080)\nlet c2 = c1.with(port: 9000)\nprint(c1.port, c2.port, c2.host)"}],"meta":{"output":"8080 9000 localhost"}} {"messages":[{"role":"user","content":"Write a Mycel program defining an RGBColor struct with red, green, blue fields."},{"role":"assistant","content":"struct RGBColor { let r: Int, g: Int, b: Int }\nlet white = RGBColor(r: 255, g: 255, b: 255)\nlet gray = white.with(r: 128, g: 128, b: 128)\nprint(white.r, gray.r)"}],"meta":{"output":"255 128"}} {"messages":[{"role":"user","content":"Write a Mycel program defining an immutable DateVal struct with year, month, day."},{"role":"assistant","content":"struct DateVal { let year: Int, month: Int, day: Int }\nlet d1 = DateVal(year: 2026, month: 11, day: 7)\nlet d2 = d1.with(day: 8)\nprint(f\"{d1.year}-{d1.month}-{d1.day}\")\nprint(f\"{d2.year}-{d2.month}-{d2.day}\")"}],"meta":{"output":"2026-11-7\n2026-11-8"}} {"messages":[{"role":"user","content":"Write a Mycel program with a struct representing a Money value (currency and amount in cents)."},{"role":"assistant","content":"struct Money { let currency: String, cents: Int }\nlet m1 = Money(currency: \"USD\", cents: 1500)\nlet m2 = m1.with(cents: 2000)\nprint(m1.currency, m1.cents, m2.cents)"}],"meta":{"output":"USD 1500 2000"}} {"messages":[{"role":"user","content":"Write a Mycel program with a struct containing a method."},{"role":"assistant","content":"struct Size { let w: Int, h: Int\n fn area() -> Int => self.w * self.h\n}\nlet s = Size(w: 6, h: 7)\nprint(f\"Area: {s.area()}\")"}],"meta":{"output":"Area: 42"}} {"messages":[{"role":"user","content":"Write a Mycel program with an array of structs sorted by a field."},{"role":"assistant","content":"struct UserScore { let name: String, score: Int }\nlet table = [UserScore(name: \"A\", score: 50), UserScore(name: \"B\", score: 90), UserScore(name: \"C\", score: 75)]\nlet sorted = table.sortedBy(u => u.score)\nfor u in sorted {\n print(f\"{u.name}: {u.score}\")\n}"}],"meta":{"output":"A: 50\nC: 75\nB: 90"}} {"messages":[{"role":"user","content":"Write a Mycel program testing that structs are immutable values and cannot be mutated directly."},{"role":"assistant","content":"struct Coord { let x: Int, y: Int }\nlet c1 = Coord(x: 1, y: 2)\nlet c2 = c1.with(x: 10)\nprint(c1.x, c2.x)"}],"meta":{"output":"1 10"}} {"messages":[{"role":"user","content":"Write a Mycel program with a LineSegment struct made of two Point structs."},{"role":"assistant","content":"struct Point { let x: Int, y: Int }\nstruct Line { let start: Point, end: Point }\nlet line = Line(start: Point(x: 0, y: 0), end: Point(x: 10, y: 20))\nprint(line.start.x, line.end.y)"}],"meta":{"output":"0 20"}} {"messages":[{"role":"user","content":"Write a Mycel program with a struct representing an HTTP Header (name, value)."},{"role":"assistant","content":"struct Header { let name: String, value: String }\nlet h1 = Header(name: \"Content-Type\", value: \"application/json\")\nprint(f\"{h1.name}: {h1.value}\")"}],"meta":{"output":"Content-Type: application/json"}} {"messages":[{"role":"user","content":"Write a Mycel program using a struct as a return type for complex calculation results."},{"role":"assistant","content":"struct DivResult { let quotient: Int, remainder: Int }\nfn divide(a: Int, b: Int) -> DivResult {\n return DivResult(quotient: a.div(b), remainder: a % b)\n}\nlet r = divide(25, 4)\nprint(r.quotient, r.remainder)"}],"meta":{"output":"6 1"}} {"messages":[{"role":"user","content":"Write a Mycel program checking structural equality of nested structs."},{"role":"assistant","content":"struct Inner { let val: Int }\nstruct Outer { let inner: Inner }\nlet o1 = Outer(inner: Inner(val: 42))\nlet o2 = Outer(inner: Inner(val: 42))\nprint(o1 == o2)"}],"meta":{"output":"true"}} {"messages":[{"role":"user","content":"Write a Mycel program with a GeoLocation struct (lat, lon) and a string formatter."},{"role":"assistant","content":"struct GeoLocation { let lat: Float, lon: Float }\nlet loc = GeoLocation(lat: 35.6762, lon: 139.6503)\nprint(f\"Lat: {loc.lat:.2f}, Lon: {loc.lon:.2f}\")"}],"meta":{"output":"Lat: 35.68, Lon: 139.65"}} {"messages":[{"role":"user","content":"Write a Mycel program that filters a list of structs with a predicate."},{"role":"assistant","content":"struct Product { let name: String, inStock: Bool }\nlet catalog = [Product(name: \"Hat\", inStock: true), Product(name: \"Coat\", inStock: false), Product(name: \"Boots\", inStock: true)]\nlet available = catalog.filter(p => p.inStock)\nfor p in available { print(p.name) }"}],"meta":{"output":"Hat\nBoots"}} {"messages":[{"role":"user","content":"Write a Mycel program defining a Direction enum (North, South, East, West) and matching on it."},{"role":"assistant","content":"enum Direction { North, South, East, West }\nfn describe(d: Direction) -> String {\n return match d {\n .North => \"Heading North\"\n .South => \"Heading South\"\n .East => \"Heading East\"\n .West => \"Heading West\"\n }\n}\nprint(describe(Direction.North))\nprint(describe(.East))"}],"meta":{"output":"Heading North\nHeading East"}} {"messages":[{"role":"user","content":"Write a Mycel program defining a Shape enum with payloads: Circle(r: Float) and Rect(w: Float, h: Float)."},{"role":"assistant","content":"enum Shape {\n Circle(r: Float)\n Rect(w: Float, h: Float)\n}\nfn area(s: Shape) -> Float {\n return match s {\n .Circle(r) => 3.14159 * r * r\n .Rect(w, h) => w * h\n }\n}\nprint(f\"{area(.Circle(r: 2.0)):.2f}\")\nprint(f\"{area(.Rect(w: 3.0, h: 4.0)):.2f}\")"}],"meta":{"output":"12.57\n12.00"}} {"messages":[{"role":"user","content":"Write a Mycel program with an enum representing Web traffic status codes."},{"role":"assistant","content":"enum Status { Ok, NotFound, ServerError }\nfn code(s: Status) -> Int => match s {\n .Ok => 200\n .NotFound => 404\n .ServerError => 500\n}\nprint(code(.Ok), code(.NotFound))"}],"meta":{"output":"200 404"}} {"messages":[{"role":"user","content":"Write a Mycel program that uses match on an integer with wildcard `_`."},{"role":"assistant","content":"fn label(n: Int) -> String => match n {\n 1 => \"one\"\n 2 => \"two\"\n 3 => \"three\"\n _ => \"many\"\n}\nprint(label(1), label(2), label(99))"}],"meta":{"output":"one two many"}} {"messages":[{"role":"user","content":"Write a Mycel program matching on strings with multiple cases."},{"role":"assistant","content":"fn roleLevel(role: String) -> Int => match role {\n \"admin\" => 10\n \"editor\" => 5\n \"viewer\" => 1\n _ => 0\n}\nprint(roleLevel(\"admin\"), roleLevel(\"guest\"))"}],"meta":{"output":"10 0"}} {"messages":[{"role":"user","content":"Write a Mycel program using match guards (`if condition`) on number ranges."},{"role":"assistant","content":"fn categorize(age: Int) -> String => match age {\n a if a < 13 => \"child\"\n a if a < 20 => \"teen\"\n a if a < 65 => \"adult\"\n _ => \"senior\"\n}\nprint(categorize(8), categorize(16), categorize(45), categorize(70))"}],"meta":{"output":"child teen adult senior"}} {"messages":[{"role":"user","content":"Write a Mycel program matching on a list pattern `[first, ..rest]`."},{"role":"assistant","content":"fn describeList(items: [Int]) -> String => match items {\n [] => \"empty\"\n [single] => f\"single: {single}\"\n [first, ..rest] => f\"first: {first}, remaining: {rest.length}\"\n}\nprint(describeList([]))\nprint(describeList([42]))\nprint(describeList([1, 2, 3]))"}],"meta":{"output":"empty\nsingle: 42\nfirst: 1, remaining: 2"}} {"messages":[{"role":"user","content":"Write a Mycel program with an enum that has methods and properties."},{"role":"assistant","content":"enum TrafficLight {\n Red, Yellow, Green\n get canGo: Bool => match self {\n .Green => true\n _ => false\n }\n}\nprint(TrafficLight.Red.canGo, TrafficLight.Green.canGo)"}],"meta":{"output":"false true"}} {"messages":[{"role":"user","content":"Write a Mycel program matching on a Result enum (.Ok and .Err)."},{"role":"assistant","content":"fn checkResult(r: Result) -> String => match r {\n .Ok(val) => f\"Success with {val}\"\n .Err(e) => f\"Failed with {e.message}\"\n}\nprint(checkResult(.Ok(100)))\nprint(checkResult(.Err(Error(\"network down\"))))"}],"meta":{"output":"Success with 100\nFailed with network down"}} {"messages":[{"role":"user","content":"Write a Mycel program matching on optional values with .Ok and nil."},{"role":"assistant","content":"fn formatOpt(x: String?) -> String => match x {\n nil => \"No value\"\n s => f\"Value: {s!}\"\n}\nprint(formatOpt(nil), formatOpt(\"Found\"))"}],"meta":{"output":"No value Value: Found"}} {"messages":[{"role":"user","content":"Write a Mycel program with a Message enum representing Chat, Join, Leave events."},{"role":"assistant","content":"enum Event {\n Join(user: String)\n Chat(user: String, text: String)\n Leave(user: String)\n}\nfn render(e: Event) -> String => match e {\n .Join(u) => f\"--> {u} joined\"\n .Chat(u, msg) => f\"<{u}> {msg}\"\n .Leave(u) => f\"<-- {u} left\"\n}\nprint(render(.Join(user: \"Ada\")))\nprint(render(.Chat(user: \"Ada\", text: \"Hello!\")))\nprint(render(.Leave(user: \"Ada\")))"}],"meta":{"output":"--> Ada joined\n Hello!\n<-- Ada left"}} {"messages":[{"role":"user","content":"Write a Mycel program matching on a pair tuple with if/else branches."},{"role":"assistant","content":"fn comparePair(p: (Int, Int)) -> String => match p {\n (a, b) => if a == b { \"Equal\" } else if a > b { \"First larger\" } else { \"Second larger\" }\n}\nprint(comparePair((5, 5)), comparePair((10, 2)), comparePair((3, 7)))"}],"meta":{"output":"Equal First larger Second larger"}} {"messages":[{"role":"user","content":"Write a Mycel program matching on a range pattern `1..=5`."},{"role":"assistant","content":"fn rank(rating: Int) -> String => match rating {\n 1..=2 => \"Poor\"\n 3 => \"Average\"\n 4..=5 => \"Excellent\"\n _ => \"Invalid\"\n}\nprint(rank(1), rank(3), rank(5), rank(10))"}],"meta":{"output":"Poor Average Excellent Invalid"}} {"messages":[{"role":"user","content":"Write a Mycel program that uses match as an expression assigned to a variable."},{"role":"assistant","content":"let day = \"Sat\"\nlet isWeekend = match day {\n \"Sat\" => true\n \"Sun\" => true\n _ => false\n}\nprint(isWeekend)"}],"meta":{"output":"true"}} {"messages":[{"role":"user","content":"Write a Mycel program with a recursive enum representing an arithmetic expression tree."},{"role":"assistant","content":"enum Expr {\n Num(Int)\n Add(Int, Int)\n Mul(Int, Int)\n}\nfn eval(e: Expr) -> Int => match e {\n .Num(n) => n\n .Add(a, b) => a + b\n .Mul(a, b) => a * b\n}\nprint(eval(.Num(5)), eval(.Add(3, 4)), eval(.Mul(6, 7)))"}],"meta":{"output":"5 7 42"}} {"messages":[{"role":"user","content":"Write a Mycel program matching boolean values exhaustively without wildcard."},{"role":"assistant","content":"fn boolText(b: Bool) -> String => match b {\n true => \"YES\"\n false => \"NO\"\n}\nprint(boolText(true), boolText(false))"}],"meta":{"output":"YES NO"}} {"messages":[{"role":"user","content":"Write a Mycel program matching enum with multiple variants using comma separation."},{"role":"assistant","content":"enum Season { Spring, Summer, Autumn, Winter }\nfn isWarm(s: Season) -> Bool => match s {\n .Summer => true\n .Spring => true\n _ => false\n}\nprint(isWarm(.Summer), isWarm(.Winter))"}],"meta":{"output":"true false"}} {"messages":[{"role":"user","content":"Write a Mycel program matching an optional integer with `nil` and `some` bindings."},{"role":"assistant","content":"fn unwrapOrDefault(opt: Int?, def: Int) -> Int => match opt {\n nil => def\n x => x!\n}\nprint(unwrapOrDefault(nil, 42), unwrapOrDefault(10, 42))"}],"meta":{"output":"42 10"}} {"messages":[{"role":"user","content":"Write a Mycel program checking leading dot enum notation when passing to a typed function parameter."},{"role":"assistant","content":"enum Priority { Low, Medium, High }\nfn handle(p: Priority) -> String => match p {\n .Low => \"Later\"\n .Medium => \"Soon\"\n .High => \"Now!\"\n}\nprint(handle(.High))"}],"meta":{"output":"Now!"}} {"messages":[{"role":"user","content":"Write a Mycel program matching on a 3-element list pattern."},{"role":"assistant","content":"fn matchTriple(items: [Int]) -> String => match items {\n [a, b, c] => f\"Triplet: {a}+{b}+{c} = {a+b+c}\"\n _ => \"Not a triplet\"\n}\nprint(matchTriple([1, 2, 3]), matchTriple([1, 2]))"}],"meta":{"output":"Triplet: 1+2+3 = 6 Not a triplet"}} {"messages":[{"role":"user","content":"Write a Mycel program matching on temperature thresholds with pattern guards."},{"role":"assistant","content":"fn stateOfWater(temp: Int) -> String => match temp {\n t if t <= 0 => \"Solid (Ice)\"\n t if t >= 100 => \"Gas (Steam)\"\n _ => \"Liquid (Water)\"\n}\nprint(stateOfWater(-5), stateOfWater(25), stateOfWater(105))"}],"meta":{"output":"Solid (Ice) Liquid (Water) Gas (Steam)"}} {"messages":[{"role":"user","content":"Write a Mycel program defining a Command enum with Quit, Help, and Move(dx: Int, dy: Int)."},{"role":"assistant","content":"enum Command {\n Quit\n Help\n Move(dx: Int, dy: Int)\n}\nfn execute(cmd: Command) -> String => match cmd {\n .Quit => \"Exiting...\"\n .Help => \"Showing help...\"\n .Move(x, y) => f\"Moving by ({x}, {y})\"\n}\nprint(execute(.Help))\nprint(execute(.Move(dx: 5, dy: -2)))"}],"meta":{"output":"Showing help...\nMoving by (5, -2)"}} {"messages":[{"role":"user","content":"Write a Mycel program with a Json-like tree enum matching."},{"role":"assistant","content":"enum SimpleVal { Str(String), Num(Int) }\nfn toStr(v: SimpleVal) -> String => match v {\n .Str(s) => s\n .Num(n) => f\"{n}\"\n}\nprint(toStr(.Str(\"hello\")), toStr(.Num(42)))"}],"meta":{"output":"hello 42"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating that missing match arms on an enum causes a compile error if not exhaustive."},{"role":"assistant","content":"enum Flag { On, Off }\nfn inspect(f: Flag) -> String => match f {\n .On => \"Active\"\n .Off => \"Inactive\"\n}\nprint(inspect(.On), inspect(.Off))"}],"meta":{"output":"Active Inactive"}} {"messages":[{"role":"user","content":"Write a Mycel program matching on characters."},{"role":"assistant","content":"fn charType(c: Char) -> String => match c {\n 'a' => \"first vowel\"\n 'z' => \"last letter\"\n _ => \"other\"\n}\nprint(charType('a'), charType('z'), charType('m'))"}],"meta":{"output":"first vowel last letter other"}} {"messages":[{"role":"user","content":"Write a Mycel program defining a Describable interface and implementing it in a class."},{"role":"assistant","content":"interface Describable {\n fn describe() -> String\n}\nclass Widget: Describable {\n let name: String\n init(name: String) { self.name = name }\n fn describe() -> String => f\"Widget({self.name})\"\n}\nlet w: Describable = Widget(name: \"Gear\")\nprint(w.describe())"}],"meta":{"output":"Widget(Gear)"}} {"messages":[{"role":"user","content":"Write a Mycel program with an interface containing a default method."},{"role":"assistant","content":"interface Greeter {\n fn name() -> String\n fn hello() -> String => f\"Hello, {self.name()}!\"\n}\nclass Bot: Greeter {\n fn name() -> String => \"MycelBot\"\n}\nlet b = Bot()\nprint(b.hello())"}],"meta":{"output":"Hello, MycelBot!"}} {"messages":[{"role":"user","content":"Write a Mycel program where a class implements multiple interfaces."},{"role":"assistant","content":"interface Named { fn name() -> String }\ninterface Sized { fn size() -> Int }\nclass BoxItem: Named, Sized {\n fn name() -> String => \"StorageBox\"\n fn size() -> Int => 50\n}\nlet b = BoxItem()\nprint(f\"{b.name()}: {b.size()}L\")"}],"meta":{"output":"StorageBox: 50L"}} {"messages":[{"role":"user","content":"Write a Mycel program extending Int with a squared() method."},{"role":"assistant","content":"extend Int {\n fn squared() -> Int => self * self\n}\nprint(7.squared(), 12.squared())"}],"meta":{"output":"49 144"}} {"messages":[{"role":"user","content":"Write a Mycel program extending String with an isBlank() method."},{"role":"assistant","content":"extend String {\n fn isBlank() -> Bool => self.trim().isEmpty\n}\nprint(\" \".isBlank(), \"hello\".isBlank())"}],"meta":{"output":"true false"}} {"messages":[{"role":"user","content":"Write a Mycel program extending String with a wordCount() method."},{"role":"assistant","content":"extend String {\n fn wordCount() -> Int => self.trim().split(\" \").filter(w => !w.isEmpty).length\n}\nprint(\"The quick brown fox\".wordCount())"}],"meta":{"output":"4"}} {"messages":[{"role":"user","content":"Write a Mycel program extending Array with a sumInts() method."},{"role":"assistant","content":"extend [Int] {\n fn sumInts() -> Int => sum(self)\n}\nprint([10, 20, 30].sumInts())"}],"meta":{"output":"60"}} {"messages":[{"role":"user","content":"Write a Mycel program extending Float with a toDollars() string formatter."},{"role":"assistant","content":"extend Float {\n fn toDollars() -> String => f\"${self:.2f}\"\n}\nprint(19.99.toDollars())"}],"meta":{"output":"$19.99"}} {"messages":[{"role":"user","content":"Write a Mycel program with an interface hierarchy where one interface extends another."},{"role":"assistant","content":"interface BaseShape { fn area() -> Float }\ninterface ColoredShape: BaseShape { fn color() -> String }\nclass RedCircle: ColoredShape {\n fn area() -> Float => 3.14159\n fn color() -> String => \"red\"\n}\nlet c = RedCircle()\nprint(f\"{c.color()} shape area: {c.area():.2f}\")"}],"meta":{"output":"red shape area: 3.14"}} {"messages":[{"role":"user","content":"Write a Mycel program extending Int with a factorial() method."},{"role":"assistant","content":"extend Int {\n fn factorial() -> Int {\n var res = 1\n for i in 1..=self { res *= i }\n return res\n }\n}\nprint(5.factorial())"}],"meta":{"output":"120"}} {"messages":[{"role":"user","content":"Write a Mycel program that extends Char with a isVowel() method."},{"role":"assistant","content":"extend Char {\n fn isVowel() -> Bool => self in \"aeiouAEIOU\"\n}\nprint('e'.isVowel(), 'k'.isVowel())"}],"meta":{"output":"true false"}} {"messages":[{"role":"user","content":"Write a Mycel program with a function taking any object conforming to Printable."},{"role":"assistant","content":"fn logItem(p: Printable) {\n print(f\"[LOG] {p.toString()}\")\n}\nclass Item: Printable {\n fn toString() -> String => \"CustomItem\"\n}\nlogItem(Item())"}],"meta":{"output":"[LOG] CustomItem"}} {"messages":[{"role":"user","content":"Write a Mycel program that extends String with a duplicate(n) method."},{"role":"assistant","content":"extend String {\n fn dup(n: Int) -> String => self.repeat(n)\n}\nprint(\"abc\".dup(3))"}],"meta":{"output":"abcabcabc"}} {"messages":[{"role":"user","content":"Write a Mycel program extending Int with an isPrime() method."},{"role":"assistant","content":"extend Int {\n fn isPrime() -> Bool {\n if self < 2 { return false }\n for d in 2..self {\n if self % d == 0 { return false }\n }\n return true\n }\n}\nprint(7.isPrime(), 10.isPrime(), 13.isPrime())"}],"meta":{"output":"true false true"}} {"messages":[{"role":"user","content":"Write a Mycel program extending Array with a second element method."},{"role":"assistant","content":"extend [T] {\n fn second() -> T? => if self.length > 1 { self[1] } else { nil }\n}\nprint([10, 20, 30].second(), [10].second() == nil)"}],"meta":{"output":"20 true"}} {"messages":[{"role":"user","content":"Write a Mycel program that wraps a success and failure in Result and tests .isOk and .isErr."},{"role":"assistant","content":"fn parsePositive(text: String) -> Result {\n let n = Int.parse(text)\n if n == nil { return .Err(Error(\"invalid number\")) }\n if n! <= 0 { return .Err(Error(\"must be positive\")) }\n return .Ok(n!)\n}\nprint(parsePositive(\"42\").isOk)\nprint(parsePositive(\"-5\").isErr)"}],"meta":{"output":"true\ntrue"}} {"messages":[{"role":"user","content":"Write a Mycel program using the `?` operator to propagate Results across multiple function calls."},{"role":"assistant","content":"fn step1() -> Result => .Ok(10)\nfn step2(n: Int) -> Result => .Ok(n * 2)\nfn workflow() -> Result {\n let a = step1()?\n let b = step2(a)?\n return .Ok(b + 5)\n}\nprint(workflow().unwrap())"}],"meta":{"output":"25"}} {"messages":[{"role":"user","content":"Write a Mycel program that uses .unwrapOr() on a Result to supply a default fallback."},{"role":"assistant","content":"let r1: Result = .Ok(42)\nlet r2: Result = .Err(Error(\"failed\"))\nprint(r1.unwrapOr(0), r2.unwrapOr(0))"}],"meta":{"output":"42 0"}} {"messages":[{"role":"user","content":"Write a Mycel program using try / catch to handle thrown Error exceptions."},{"role":"assistant","content":"fn risky(fail: Bool) {\n if fail { throw Error(\"Something broke!\") }\n print(\"All good\")\n}\ntry {\n risky(false)\n risky(true)\n} catch e {\n print(f\"Caught error: {e.message}\")\n}"}],"meta":{"output":"All good\nCaught error: Something broke!"}} {"messages":[{"role":"user","content":"Write a Mycel program with a custom Error subclass and typed catch block."},{"role":"assistant","content":"class ValidationError: Error {}\nfn validateAge(age: Int) {\n if age < 0 { throw ValidationError(\"Negative age\") }\n}\ntry {\n validateAge(-1)\n} catch e: ValidationError {\n print(f\"Validation failed: {e.message}\")\n}"}],"meta":{"output":"Validation failed: Negative age"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating the finally block in try / catch."},{"role":"assistant","content":"var cleanedUp = false\ntry {\n throw Error(\"Oops\")\n} catch e {\n print(\"Handling error\")\n} finally {\n cleanedUp = true\n}\nprint(f\"Cleaned up: {cleanedUp}\")"}],"meta":{"output":"Handling error\nCleaned up: true"}} {"messages":[{"role":"user","content":"Write a Mycel program that maps a Result value using .map()."},{"role":"assistant","content":"let r: Result = .Ok(21)\nlet doubled = r.map(x => x * 2)\nprint(doubled.unwrap())"}],"meta":{"output":"42"}} {"messages":[{"role":"user","content":"Write a Mycel program using try expression to turn a throwing call into a Result."},{"role":"assistant","content":"fn thrower() -> Int {\n throw Error(\"Kaboom\")\n}\nlet res = try thrower()\nprint(res.isErr)"}],"meta":{"output":"true"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating unwrap on an Ok Result."},{"role":"assistant","content":"let r: Result = .Ok(\"payload\")\nprint(r.unwrap())"}],"meta":{"output":"payload"}} {"messages":[{"role":"user","content":"Write a Mycel program handling multiple error types in sequence."},{"role":"assistant","content":"class ParseErr: Error {}\nclass RangeErr: Error {}\nfn parseInRange(s: String) {\n let n = Int.parse(s)\n if n == nil { throw ParseErr(\"not an int\") }\n if n! < 0 || n! > 100 { throw RangeErr(\"out of range\") }\n print(f\"Valid: {n!}\")\n}\ntry {\n parseInRange(\"abc\")\n} catch e: ParseErr {\n print(\"Parse issue\")\n}\ntry {\n parseInRange(\"999\")\n} catch e: RangeErr {\n print(\"Range issue\")\n}"}],"meta":{"output":"Parse issue\nRange issue"}} {"messages":[{"role":"user","content":"Write a Mycel program that chains Results with .andThen()."},{"role":"assistant","content":"fn parseNum(s: String) -> Result {\n let n = Int.parse(s)\n if n == nil { return .Err(Error(\"bad\")) }\n return .Ok(n!)\n}\nfn mustBePositive(n: Int) -> Result {\n if n <= 0 { return .Err(Error(\"negative\")) }\n return .Ok(n)\n}\nlet res = parseNum(\"50\").andThen(n => mustBePositive(n))\nprint(res.isOk, res.unwrap())"}],"meta":{"output":"true 50"}} {"messages":[{"role":"user","content":"Write a Mycel program that maps an error message with .mapErr()."},{"role":"assistant","content":"let r: Result = .Err(Error(\"low-level error\"))\nlet mapped = r.mapErr(e => Error(f\"High-level context: {e.message}\"))\nprint(mapped.err()?.message)"}],"meta":{"output":"High-level context: low-level error"}} {"messages":[{"role":"user","content":"Write a Mycel program that catches an error, logs it, and re-throws a wrapped error."},{"role":"assistant","content":"fn process() {\n try {\n throw Error(\"disk error\")\n } catch e {\n throw Error(f\"App error caused by {e.message}\")\n }\n}\ntry {\n process()\n} catch e {\n print(e.message)\n}"}],"meta":{"output":"App error caused by disk error"}} {"messages":[{"role":"user","content":"Write a Mycel program that returns an optional .ok() from a Result."},{"role":"assistant","content":"let r: Result = .Ok(123)\nprint(r.ok())\nlet rErr: Result = .Err(Error(\"fail\"))\nprint(rErr.ok() == nil)"}],"meta":{"output":"123\ntrue"}} {"messages":[{"role":"user","content":"Write a Mycel program that returns an optional .err() from a Result."},{"role":"assistant","content":"let r: Result = .Err(Error(\"boom\"))\nprint(r.err()?.message)"}],"meta":{"output":"boom"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.math to calculate the square root of 144.0."},{"role":"assistant","content":"import std.math\nprint(math.sqrt(144.0))"}],"meta":{"output":"12.0"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.math to calculate sine and cosine of math.PI / 2.0."},{"role":"assistant","content":"import std.math\nlet angle = math.PI / 2.0\nprint(f\"sin: {math.sin(angle):.1f}\")"}],"meta":{"output":"sin: 1.0"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.math to find the hypotenuse of a right triangle with sides 3.0 and 4.0."},{"role":"assistant","content":"import std.math\nprint(math.hypot(3.0, 4.0))"}],"meta":{"output":"5.0"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.math to calculate the greatest common divisor of 54 and 24."},{"role":"assistant","content":"import std.math\nprint(math.gcd(54, 24))"}],"meta":{"output":"6"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.json to encode an array and map into JSON text."},{"role":"assistant","content":"import std.json\nlet data: {String: Any} = {\"name\": \"Mycel\", \"version\": 1}\nprint(json.encode(data))"}],"meta":{"output":"{\"name\":\"Mycel\",\"version\":1}"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.json to parse JSON text and access fields."},{"role":"assistant","content":"import std.json\nlet text = \"{\\\"score\\\": 98, \\\"user\\\": \\\"ada\\\"}\"\nlet parsed = json.parse(text).unwrap()\nprint(parsed[\"user\"], parsed[\"score\"])"}],"meta":{"output":"ada 98"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.crypto to compute the sha256 hash of 'mycel'."},{"role":"assistant","content":"import std.crypto\nlet h = crypto.sha256(\"mycel\")\nprint(h.substring(0, 16))"}],"meta":{"output":"5536012d3c5217d5"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.crypto to generate a UUID string."},{"role":"assistant","content":"import std.crypto\nlet u = crypto.uuid()\nprint(u.length == 36)"}],"meta":{"output":"true"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.crypto to base64 encode and decode a string."},{"role":"assistant","content":"import std.crypto\nlet original = \"Hello Mycel!\"\nlet enc = crypto.base64Encode(original)\nprint(enc)\nlet dec = crypto.base64Decode(enc).unwrap()\nprint(dec)"}],"meta":{"output":"SGVsbG8gTXljZWwh\nHello Mycel!"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.re to check if an email matches a basic regex pattern."},{"role":"assistant","content":"import std.re\nlet r = re.Regex.compile(\"^[a-z]+@[a-z]+\\\\.[a-z]+$\").unwrap()\nprint(r.isMatch(\"test@example.com\"))\nprint(r.isMatch(\"bad-email\"))"}],"meta":{"output":"true\nfalse"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.re to find all numbers in a string."},{"role":"assistant","content":"import std.re\nlet r = re.Regex.compile(\"\\\\d+\").unwrap()\nlet matches = r.findAll(\"Item 1 costs $25, Item 2 costs $80\")\nfor m in matches {\n write(f\"{m.text} \")\n}\nprint(\"\")"}],"meta":{"output":"1 25 2 80"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.re to replace all digits with an 'X'."},{"role":"assistant","content":"import std.re\nlet r = re.Regex.compile(\"\\\\d\").unwrap()\nprint(r.replace(\"Pin: 1234\", \"X\"))"}],"meta":{"output":"Pin: XXXX"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.time to get current date as YYYY-MM-DD."},{"role":"assistant","content":"import std.time\nlet d = time.today()\nprint(d.length == 10)"}],"meta":{"output":"true"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.time.Duration to convert 3 minutes to seconds and milliseconds."},{"role":"assistant","content":"import std.time\nlet dur = time.minutes(3)\nprint(dur.toSeconds(), dur.toMs())"}],"meta":{"output":"180.0 180000"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.env to check an environment variable or default."},{"role":"assistant","content":"import std.env\nlet p = env.get(\"NONEXISTENT_VAR\").unwrap() ?? \"my_default\"\nprint(p)"}],"meta":{"output":"my_default"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.fs to write and read text from a temporary file."},{"role":"assistant","content":"import std.fs\nfn main() {\n let tmp = \"mycel_instruct_test.txt\"\n fs.writeText(tmp, \"Hello from std.fs!\").unwrap()\n let content = fs.readText(tmp).unwrap()\n print(content)\n fs.remove(tmp).unwrap()\n}"}],"meta":{"output":"Hello from std.fs!"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.fs to test file existence."},{"role":"assistant","content":"import std.fs\nfn main() {\n let tmp = \"mycel_exists_check.txt\"\n print(fs.exists(tmp).unwrap())\n fs.writeText(tmp, \"exists\").unwrap()\n print(fs.exists(tmp).unwrap())\n fs.remove(tmp).unwrap()\n}"}],"meta":{"output":"false\ntrue"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.json pretty-printing on a nested Json object."},{"role":"assistant","content":"import std.json\nlet doc = json.parse(\"{\\\"a\\\": 1, \\\"b\\\": [2, 3]}\").unwrap()\nprint(json.stringify(doc))"}],"meta":{"output":"{\"a\":1,\"b\":[2,3]}"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.math to convert degrees to radians and back."},{"role":"assistant","content":"import std.math\nlet rad = math.radians(180.0)\nlet deg = math.degrees(rad)\nprint(f\"Rad: {rad:.4f}, Deg: {deg:.1f}\")"}],"meta":{"output":"Rad: 3.1416, Deg: 180.0"}} {"messages":[{"role":"user","content":"Write a Mycel program using std.crypto to generate a random 8-byte hex string."},{"role":"assistant","content":"import std.crypto\nlet hex = crypto.randomHex(8)\nprint(hex.length == 16)"}],"meta":{"output":"true"}} {"messages":[{"role":"user","content":"Write a Mycel program defining a unit test block using test \"...\"."},{"role":"assistant","content":"test \"basic addition\" {\n assert(1 + 1 == 2, \"math works\")\n}\nprint(\"tests passed\")"}],"meta":{"output":"tests passed"}} {"messages":[{"role":"user","content":"Write a Mycel program defining multiple unit test blocks."},{"role":"assistant","content":"test \"string length\" {\n assert(\"abc\".length == 3)\n}\ntest \"array operations\" {\n var a = [1, 2]\n a.push(3)\n assert(a.length == 3)\n}\nprint(\"all tests verified\")"}],"meta":{"output":"all tests verified"}} {"messages":[{"role":"user","content":"Write a Mycel program with a generator function that yields numbers 1, 2, 3."},{"role":"assistant","content":"gen fn count3() -> Gen {\n yield 1\n yield 2\n yield 3\n}\nfor n in count3() {\n write(f\"{n} \")\n}\nprint(\"\")"}],"meta":{"output":"1 2 3"}} {"messages":[{"role":"user","content":"Write a Mycel program with a generator function that yields elements of an array doubled."},{"role":"assistant","content":"gen fn doubleEach(items: [Int]) -> Gen {\n for item in items {\n yield item * 2\n }\n}\nlet res = doubleEach([5, 10, 15]).toArray()\nprint(res)"}],"meta":{"output":"[10, 20, 30]"}} {"messages":[{"role":"user","content":"Write a Mycel program with a generator yielding Fibonacci sequence up to n terms."},{"role":"assistant","content":"gen fn fibGen(count: Int) -> Gen {\n var a = 0\n var b = 1\n for _ in 0..count {\n yield a\n let next = a + b\n a = b\n b = next\n }\n}\nprint(fibGen(6).toArray())"}],"meta":{"output":"[0, 1, 1, 2, 3, 5]"}} {"messages":[{"role":"user","content":"Write a Mycel program demonstrating the assert() function with condition."},{"role":"assistant","content":"assert(2 * 2 == 4)\nassert(\"mycel\".startsWith(\"my\"))\nprint(\"Assertions passed\")"}],"meta":{"output":"Assertions passed"}} {"messages":[{"role":"user","content":"Write a Mycel program that transforms a list using pipeline operator `|>`."},{"role":"assistant","content":"fn doubleAll(xs: [Int]) -> [Int] => xs.map(x => x * 2)\nfn sumAll(xs: [Int]) -> Int => sum(xs)\nlet total = [1, 2, 3, 4] |> doubleAll |> sumAll\nprint(total)"}],"meta":{"output":"20"}} {"messages":[{"role":"user","content":"Write a Mycel program with a generator that filters values."},{"role":"assistant","content":"gen fn evensOnly(items: [Int]) -> Gen {\n for x in items {\n if x % 2 == 0 { yield x }\n }\n}\nprint(evensOnly([1, 2, 3, 4, 5, 6]).toArray())"}],"meta":{"output":"[2, 4, 6]"}} {"messages":[{"role":"user","content":"Write a Mycel program showing that `test` blocks can assert map and set values."},{"role":"assistant","content":"test \"set and map\" {\n let s = Set([1, 2])\n assert(s.has(1))\n let m = {\"k\": \"v\"}\n assert(m[\"k\"] == \"v\")\n}\nprint(\"collection test ok\")"}],"meta":{"output":"collection test ok"}} {"messages":[{"role":"user","content":"Write a Mycel program chaining generator output into an array and sorting it."},{"role":"assistant","content":"gen fn unsortedGen() -> Gen {\n yield 40\n yield 10\n yield 30\n yield 20\n}\nprint(unsortedGen().toArray().sorted())"}],"meta":{"output":"[10, 20, 30, 40]"}} {"messages":[{"role":"user","content":"Write a Mycel program that prompts the user for their name and greets them."},{"role":"assistant","content":"let name = input(\"Enter your name: \")\nprint(f\"Hello, {name}!\")"}],"meta":{"output":"Enter your name: Hello, Alex!","inputs":["Alex"]}} {"messages":[{"role":"user","content":"Write a Mycel program that reads two numbers from input and prints their sum."},{"role":"assistant","content":"let aStr = input(\"First number: \")\nlet bStr = input(\"Second number: \")\nlet a = Int.parse(aStr) ?? 0\nlet b = Int.parse(bStr) ?? 0\nprint(f\"Sum: {a + b}\")"}],"meta":{"output":"First number: Second number: Sum: 40","inputs":["15","25"]}} {"messages":[{"role":"user","content":"Write a Mycel program that asks for a temperature in Celsius and displays it in Fahrenheit."},{"role":"assistant","content":"let cStr = input(\"Celsius: \")\nlet c = Float.parse(cStr) ?? 0.0\nlet f = (c * 9.0 / 5.0) + 32.0\nprint(f\"Fahrenheit: {f:.1f}\")"}],"meta":{"output":"Celsius: Fahrenheit: 77.0","inputs":["25.0"]}} {"messages":[{"role":"user","content":"Write a Mycel program that repeatedly prompts for words until 'done' is entered."},{"role":"assistant","content":"var words: [String] = []\nwhile true {\n let w = input(\"Word: \")\n if w == \"done\" { break }\n words.push(w)\n}\nlet sep = \", \"\nprint(f\"Collected: {words.join(sep)}\")"}],"meta":{"output":"Word: Word: Word: Collected: apple, banana","inputs":["apple","banana","done"]}} {"messages":[{"role":"user","content":"Write a Mycel program that asks a quiz question and checks if the answer is correct."},{"role":"assistant","content":"let ans = input(\"What is the capital of France? \")\nif ans.trim().lower() == \"paris\" {\n print(\"Correct!\")\n} else {\n print(\"Incorrect\")\n}"}],"meta":{"output":"What is the capital of France? Correct!","inputs":["Paris"]}} {"messages":[{"role":"user","content":"Write a Mycel program that asks for an integer and prints its multiplication table up to 5."},{"role":"assistant","content":"let nStr = input(\"Number: \")\nlet n = Int.parse(nStr) ?? 1\nfor i in 1..=5 {\n print(f\"{n} x {i} = {n * i}\")\n}"}],"meta":{"output":"Number: 4 x 1 = 4\n4 x 2 = 8\n4 x 3 = 12\n4 x 4 = 16\n4 x 5 = 20","inputs":["4"]}} {"messages":[{"role":"user","content":"Write a Mycel program that asks for a yes/no confirmation and returns a boolean."},{"role":"assistant","content":"let resp = input(\"Proceed? (y/n): \")\nlet ok = resp.lower().startsWith(\"y\")\nprint(f\"Confirmed: {ok}\")"}],"meta":{"output":"Proceed? (y/n): Confirmed: true","inputs":["yes"]}} {"messages":[{"role":"user","content":"Write a Mycel program that asks for a sentence and prints its word count."},{"role":"assistant","content":"let text = input(\"Enter text: \")\nlet count = text.trim().split(\" \").filter(w => !w.isEmpty).length\nprint(f\"Words: {count}\")"}],"meta":{"output":"Enter text: Words: 4","inputs":["Mycel makes coding readable"]}} {"messages":[{"role":"user","content":"Write a Mycel program that asks for a secret password and verifies it."},{"role":"assistant","content":"let pw = input(\"Password: \")\nif pw == \"secret123\" {\n print(\"Access granted\")\n} else {\n print(\"Access denied\")\n}"}],"meta":{"output":"Password: Access granted","inputs":["secret123"]}} {"messages":[{"role":"user","content":"Write a Mycel program that reads a list of comma-separated tags and displays them sorted."},{"role":"assistant","content":"let raw = input(\"Tags: \")\nlet tags = raw.split(\",\").map(t => t.trim()).sorted()\nlet sep = \" | \"\nprint(f\"Sorted tags: {tags.join(sep)}\")"}],"meta":{"output":"Tags: Sorted tags: go | mycel | python | rust","inputs":["rust, python, mycel, go"]}} {"messages":[{"role":"user","content":"Write a Mycel program implementing binary search on a sorted integer list."},{"role":"assistant","content":"fn binarySearch(items: [Int], target: Int) -> Int? {\n var lo = 0\n var hi = items.length - 1\n while lo <= hi {\n let mid = lo + (hi - lo).div(2)\n if items[mid] == target { return mid }\n if items[mid] < target { lo = mid + 1 } else { hi = mid - 1 }\n }\n return nil\n}\nlet nums = [2, 5, 8, 12, 16, 23, 38, 56, 72, 91]\nprint(binarySearch(nums, 23))\nprint(binarySearch(nums, 99) == nil)"}],"meta":{"output":"5\ntrue"}} {"messages":[{"role":"user","content":"Write a Mycel program implementing Bubble Sort on an array of integers."},{"role":"assistant","content":"fn bubbleSort(items: [Int]) -> [Int] {\n let arr = items.copy()\n let n = arr.length\n for i in 0..n {\n for j in 0..(n - i - 1) {\n if arr[j] > arr[j + 1] {\n let tmp = arr[j]\n arr[j] = arr[j + 1]\n arr[j + 1] = tmp\n }\n }\n }\n return arr\n}\nprint(bubbleSort([64, 34, 25, 12, 22, 11, 90]))"}],"meta":{"output":"[11, 12, 22, 25, 34, 64, 90]"}} {"messages":[{"role":"user","content":"Write a Mycel program implementing Insertion Sort."},{"role":"assistant","content":"fn insertionSort(arr: [Int]) -> [Int] {\n let res = arr.copy()\n for i in 1..res.length {\n let key = res[i]\n var j = i - 1\n while j >= 0 && res[j] > key {\n res[j + 1] = res[j]\n j -= 1\n }\n res[j + 1] = key\n }\n return res\n}\nprint(insertionSort([12, 11, 13, 5, 6]))"}],"meta":{"output":"[5, 6, 11, 12, 13]"}} {"messages":[{"role":"user","content":"Write a Mycel program that computes the Run-Length Encoding (RLE) of a string."},{"role":"assistant","content":"fn rle(s: String) -> String {\n if s.isEmpty { return \"\" }\n var encoded: [String] = []\n var currentChar = s.substring(0, 1)\n var count = 1\n for i in 1..s.length {\n let ch = s.substring(i, i + 1)\n if ch == currentChar {\n count += 1\n } else {\n encoded.push(f\"{count}{currentChar}\")\n currentChar = ch\n count = 1\n }\n }\n encoded.push(f\"{count}{currentChar}\")\n return encoded.join(\"\")\n}\nprint(rle(\"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB\"))"}],"meta":{"output":"12W1B12W3B24W1B"}} {"messages":[{"role":"user","content":"Write a Mycel program that encodes and decodes text using a Caesar cipher with a shift of 3."},{"role":"assistant","content":"fn caesar(text: String, shift: Int) -> String {\n var res: [String] = []\n for ch in text {\n if ch.isLetter {\n let base = if ch.isUpper { 'A'.code } else { 'a'.code }\n let offset = (ch.code - base + shift) % 26\n let newCode = base + (if offset < 0 { offset + 26 } else { offset })\n res.push(Char.fromCode(newCode).toString())\n } else {\n res.push(ch.toString())\n }\n }\n return res.join(\"\")\n}\nlet enc = caesar(\"Hello, Mycel!\", 3)\nprint(enc)\nlet dec = caesar(enc, -3)\nprint(dec)"}],"meta":{"output":"Khoor, Pbfho!\nHello, Mycel!"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if two strings are anagrams of each other."},{"role":"assistant","content":"fn areAnagrams(s1: String, s2: String) -> Bool {\n let clean1 = s1.lower().trim().chars().sorted()\n let clean2 = s2.lower().trim().chars().sorted()\n return clean1 == clean2\n}\nprint(areAnagrams(\"listen\", \"silent\"))\nprint(areAnagrams(\"triangle\", \"integral\"))\nprint(areAnagrams(\"apple\", \"pale\"))"}],"meta":{"output":"true\ntrue\nfalse"}} {"messages":[{"role":"user","content":"Write a Mycel program implementing a simple Todo List manager class."},{"role":"assistant","content":"class TodoList {\n var items: [String] = []\n fn add(task: String) { self.items.push(task) }\n fn complete(index: Int) -> String? {\n if index >= 0 && index < self.items.length {\n return self.items.removeAt(index)\n }\n return nil\n }\n fn listAll() {\n for i, t in self.items {\n print(f\"{i + 1}. {t}\")\n }\n }\n}\nlet todo = TodoList()\ntodo.add(\"Learn Mycel\")\ntodo.add(\"Write datasets\")\ntodo.listAll()\ntodo.complete(0)\nprint(\"Remaining:\")\ntodo.listAll()"}],"meta":{"output":"1. Learn Mycel\n2. Write datasets\nRemaining:\n1. Write datasets"}} {"messages":[{"role":"user","content":"Write a Mycel program that parses simple key=value pairs into a map."},{"role":"assistant","content":"fn parseIni(content: String) -> {String: String} {\n var conf: {String: String} = {}\n for line in content.lines() {\n let trimmed = line.trim()\n if trimmed.isEmpty || trimmed.startsWith(\"#\") { continue }\n let parts = trimmed.split(\"=\")\n if parts.length == 2 {\n conf[parts[0].trim()] = parts[1].trim()\n }\n }\n return conf\n}\nlet ini = \"\"\"\n# App config\nhost=0.0.0.0\nport=8080\nmode=production\n\"\"\"\nlet c = parseIni(ini)\nprint(c[\"host\"], c[\"port\"], c[\"mode\"])"}],"meta":{"output":"0.0.0.0 8080 production"}} {"messages":[{"role":"user","content":"Write a Mycel program that finds the longest common prefix among an array of strings."},{"role":"assistant","content":"fn longestCommonPrefix(words: [String]) -> String {\n if words.isEmpty { return \"\" }\n var prefix = words[0]\n for i in 1..words.length {\n while !words[i].startsWith(prefix) {\n prefix = prefix.substring(0, prefix.length - 1)\n if prefix.isEmpty { return \"\" }\n }\n }\n return prefix\n}\nprint(longestCommonPrefix([\"flower\", \"flow\", \"flight\"]))\nprint(longestCommonPrefix([\"dog\", \"racecar\", \"car\"]))"}],"meta":{"output":"fl"}} {"messages":[{"role":"user","content":"Write a Mycel program implementing a Matrix Transpose function."},{"role":"assistant","content":"fn transpose(m: [[Int]]) -> [[Int]] {\n let rows = m.length\n let cols = m[0].length\n var res: [[Int]] = []\n for c in 0..cols {\n var newRow: [Int] = []\n for r in 0..rows {\n newRow.push(m[r][c])\n }\n res.push(newRow)\n }\n return res\n}\nlet mat = [[1, 2, 3], [4, 5, 6]]\nprint(transpose(mat))"}],"meta":{"output":"[[1, 4], [2, 5], [3, 6]]"}} {"messages":[{"role":"user","content":"Write a Mycel program implementing Pascal's Triangle up to 5 rows."},{"role":"assistant","content":"fn pascalsTriangle(rows: Int) -> [[Int]] {\n var triangle: [[Int]] = []\n for r in 0..rows {\n var row: [Int] = [1]\n if r > 0 {\n let prev = triangle[r - 1]\n for i in 0..(prev.length - 1) {\n row.push(prev[i] + prev[i + 1])\n }\n row.push(1)\n }\n triangle.push(row)\n }\n return triangle\n}\nfor row in pascalsTriangle(5) {\n print(row)\n}"}],"meta":{"output":"[1]\n[1, 1]\n[1, 2, 1]\n[1, 3, 3, 1]\n[1, 4, 6, 4, 1]"}} {"messages":[{"role":"user","content":"Write a Mycel program implementing a simple LRU-style cache with max capacity."},{"role":"assistant","content":"class SimpleCache {\n let capacity: Int\n var keys: [String] = []\n var store: {String: String} = {}\n init(capacity: Int) { self.capacity = capacity }\n fn put(k: String, v: String) {\n if k in self.store {\n self.store[k] = v\n return\n }\n if self.keys.length >= self.capacity {\n let oldest = self.keys.removeAt(0)\n self.store.remove(oldest)\n }\n self.keys.push(k)\n self.store[k] = v\n }\n fn get(k: String) -> String? => self.store.get(k)\n}\nlet c = SimpleCache(capacity: 2)\nc.put(\"a\", \"1\")\nc.put(\"b\", \"2\")\nc.put(\"c\", \"3\")\nprint(c.get(\"a\") == nil, c.get(\"b\"), c.get(\"c\"))"}],"meta":{"output":"true 2 3"}} {"messages":[{"role":"user","content":"Write a Mycel program that computes the frequency of characters in a string."},{"role":"assistant","content":"fn charFreq(s: String) -> {String: Int} {\n var counts: {String: Int} = {}\n for ch in s {\n let k = ch.toString()\n counts[k] = counts.get(k, 0) + 1\n }\n return counts\n}\nlet f = charFreq(\"mississippi\")\nprint(f[\"m\"], f[\"i\"], f[\"s\"], f[\"p\"])"}],"meta":{"output":"1 4 4 2"}} {"messages":[{"role":"user","content":"Write a Mycel program calculating moving averages of a list of numbers with window size 3."},{"role":"assistant","content":"fn movingAverage(nums: [Float], window: Int) -> [Float] {\n var res: [Float] = []\n for i in 0..=(nums.length - window) {\n let slice = nums.slice(i, i + window)\n res.push(sum(slice) / window.toFloat())\n }\n return res\n}\nlet data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]\nlet ma = movingAverage(data, 3)\nfor m in ma { write(f\"{m:.1f} \") }\nprint(\"\")"}],"meta":{"output":"2.0 3.0 4.0 5.0"}} {"messages":[{"role":"user","content":"Write a Mycel program implementing a simple calculator parser evaluating a list of tokens."},{"role":"assistant","content":"fn calc(a: Int, op: String, b: Int) -> Int => match op {\n \"+\" => a + b\n \"-\" => a - b\n \"*\" => a * b\n \"/\" => a.div(b)\n _ => 0\n}\nprint(calc(10, \"+\", 5), calc(10, \"*\", 3), calc(10, \"/\", 2))"}],"meta":{"output":"15 30 5"}} {"messages":[{"role":"user","content":"Write a Mycel program calculating the dot product of two integer vectors."},{"role":"assistant","content":"fn dotProduct(v1: [Int], v2: [Int]) -> Int {\n var total = 0\n for p in v1.zip(v2) {\n total += p.0 * p.1\n }\n return total\n}\nprint(dotProduct([1, 2, 3], [4, 5, 6]))"}],"meta":{"output":"32"}} {"messages":[{"role":"user","content":"Write a Mycel program that computes the Sieve of Eratosthenes to find primes up to 30."},{"role":"assistant","content":"fn sieve(limit: Int) -> [Int] {\n var isP: {Int: Bool} = {}\n for i in 2..=limit { isP[i] = true }\n for p in 2..=limit {\n if isP.get(p, false) {\n var mult = p * 2\n while mult <= limit {\n isP[mult] = false\n mult += p\n }\n }\n }\n return [n for n in 2..=limit if isP.get(n, false)]\n}\nprint(sieve(30))"}],"meta":{"output":"[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]"}} {"messages":[{"role":"user","content":"Write a Mycel program that merges two sorted lists into one sorted list."},{"role":"assistant","content":"fn mergeSorted(a: [Int], b: [Int]) -> [Int] {\n var res: [Int] = []\n var i = 0\n var j = 0\n while i < a.length && j < b.length {\n if a[i] <= b[j] {\n res.push(a[i])\n i += 1\n } else {\n res.push(b[j])\n j += 1\n }\n }\n while i < a.length { res.push(a[i]); i += 1 }\n while j < b.length { res.push(b[j]); j += 1 }\n return res\n}\nprint(mergeSorted([1, 3, 5, 7], [2, 4, 6, 8]))"}],"meta":{"output":"[1, 2, 3, 4, 5, 6, 7, 8]"}} {"messages":[{"role":"user","content":"Write a Mycel program implementing QuickSort on an array of integers."},{"role":"assistant","content":"fn quickSort(arr: [Int]) -> [Int] {\n if arr.length <= 1 { return arr }\n let pivot = arr[0]\n let rest = arr.slice(1, arr.length)\n let less = rest.filter(x => x <= pivot)\n let greater = rest.filter(x => x > pivot)\n return quickSort(less).concat([pivot]).concat(quickSort(greater))\n}\nprint(quickSort([38, 27, 43, 3, 9, 82, 10]))"}],"meta":{"output":"[3, 9, 10, 27, 38, 43, 82]"}} {"messages":[{"role":"user","content":"Write a Mycel program that parses a URL query string into a map."},{"role":"assistant","content":"fn parseQuery(query: String) -> {String: String} {\n var params: {String: String} = {}\n let pairs = query.split(\"&\")\n for p in pairs {\n let parts = p.split(\"=\")\n if parts.length == 2 {\n params[parts[0]] = parts[1]\n }\n }\n return params\n}\nlet q = parseQuery(\"name=Alice&role=admin&active=true\")\nprint(q[\"name\"], q[\"role\"], q[\"active\"])"}],"meta":{"output":"Alice admin true"}} {"messages":[{"role":"user","content":"Write a Mycel program that decodes a Run-Length Encoded string."},{"role":"assistant","content":"fn decodeRle(s: String) -> String {\n var res: [String] = []\n var countStr = \"\"\n for ch in s {\n if ch.isDigit {\n countStr += ch.toString()\n } else {\n let n = Int.parse(countStr) ?? 1\n res.push(ch.toString().repeat(n))\n countStr = \"\"\n }\n }\n return res.join(\"\")\n}\nprint(decodeRle(\"3A2B4C\"))"}],"meta":{"output":"AAABBCCCC"}} {"messages":[{"role":"user","content":"Write a Mycel program converting an integer to Roman numerals (up to 20)."},{"role":"assistant","content":"fn toRoman(n: Int) -> String {\n let romans = [(10, \"X\"), (9, \"IX\"), (5, \"V\"), (4, \"IV\"), (1, \"I\")]\n var num = n\n var res = \"\"\n for pair in romans {\n while num >= pair.0 {\n res += pair.1\n num -= pair.0\n }\n }\n return res\n}\nprint(toRoman(4), toRoman(9), toRoman(14), toRoman(19))"}],"meta":{"output":"IV IX XIV XIX"}} {"messages":[{"role":"user","content":"Write a Mycel program that computes the prime factors of an integer."},{"role":"assistant","content":"fn primeFactors(n: Int) -> [Int] {\n var num = n\n var factors: [Int] = []\n var d = 2\n while d * d <= num {\n while num % d == 0 {\n factors.push(d)\n num = num.div(d)\n }\n d += 1\n }\n if num > 1 { factors.push(num) }\n return factors\n}\nprint(primeFactors(60), primeFactors(84))"}],"meta":{"output":"[2, 2, 3, 5] [2, 2, 3, 7]"}} {"messages":[{"role":"user","content":"Write a Mycel program that splits an array into chunks of size n."},{"role":"assistant","content":"fn chunkArray(items: [T], size: Int) -> [[T]] {\n var chunks: [[T]] = []\n var i = 0\n while i < items.length {\n let end = if i + size < items.length { i + size } else { items.length }\n chunks.push(items.slice(i, end))\n i += size\n }\n return chunks\n}\nprint(chunkArray([1, 2, 3, 4, 5, 6, 7], 3))"}],"meta":{"output":"[[1, 2, 3], [4, 5, 6], [7]]"}} {"messages":[{"role":"user","content":"Write a Mycel program that counts lines, words, and characters in a paragraph."},{"role":"assistant","content":"fn countStats(text: String) -> (Int, Int, Int) {\n let lines = text.lines().length\n let words = text.trim().split(\" \").filter(w => !w.isEmpty).length\n let chars = text.length\n return (lines, words, chars)\n}\nlet sample = \"Line 1\\nLine 2 with words\\nLine 3\"\nlet st = countStats(sample)\nprint(f\"Lines: {st.0}, Words: {st.1}, Chars: {st.2}\")"}],"meta":{"output":"Lines: 3, Words: 6, Chars: 31"}} {"messages":[{"role":"user","content":"Write a Mycel program implementing a Binary Search Tree (BST) insertion and in-order traversal."},{"role":"assistant","content":"class Node {\n let val: Int\n var left: Node? = nil\n var right: Node? = nil\n init(val: Int) { self.val = val }\n}\nfn insert(root: Node?, val: Int) -> Node {\n if root == nil { return Node(val: val) }\n let r = root!\n if val < r.val {\n r.left = insert(r.left, val)\n } else {\n r.right = insert(r.right, val)\n }\n return r\n}\nfn inOrder(node: Node?, out: [Int]) {\n if node == nil { return }\n let n = node!\n inOrder(n.left, out)\n out.push(n.val)\n inOrder(n.right, out)\n}\nvar tree: Node? = nil\nfor v in [5, 3, 7, 2, 4, 6, 8] {\n tree = insert(tree, v)\n}\nvar vals: [Int] = []\ninOrder(tree, vals)\nprint(vals)"}],"meta":{"output":"[2, 3, 4, 5, 6, 7, 8]"}} {"messages":[{"role":"user","content":"Write a Mycel program that parses a comma-separated values (CSV) line handling quotes."},{"role":"assistant","content":"fn parseCsvLine(line: String) -> [String] {\n return line.split(\",\").map(c => c.trim().replace(\"\\\"\", \"\"))\n}\nlet row = parseCsvLine(\"\\\"Alice\\\", 30, \\\"Engineer\\\"\")\nprint(row[0], row[1], row[2])"}],"meta":{"output":"Alice 30 Engineer"}} {"messages":[{"role":"user","content":"Write a Mycel program with a Currency Converter exchanging USD, EUR, and JPY using exchange rates in a map."},{"role":"assistant","content":"let rates: {String: Float} = {\"USD\": 1.0, \"EUR\": 0.92, \"JPY\": 150.0}\nfn convert(amount: Float, from: String, to: String) -> Float {\n let usd = amount / rates.get(from, 1.0)\n return usd * rates.get(to, 1.0)\n}\nlet eur = convert(100.0, \"USD\", \"EUR\")\nlet jpy = convert(100.0, \"USD\", \"JPY\")\nprint(f\"${eur:.2f}\")\nprint(f\"${jpy:.2f}\")"}],"meta":{"output":"$92.00\n$15000.00"}} {"messages":[{"role":"user","content":"Write a Mycel program calculating combinations nCr = n! / (r! * (n-r)!)."},{"role":"assistant","content":"fn nCr(n: Int, r: Int) -> Int {\n var num = 1\n for i in 1..=r {\n num = (num * (n - i + 1)).div(i)\n }\n return num\n}\nprint(nCr(5, 2), nCr(6, 3))"}],"meta":{"output":"10 20"}} {"messages":[{"role":"user","content":"Write a Mycel program converting seconds into hh:mm:ss format."},{"role":"assistant","content":"fn formatSeconds(total: Int) -> String {\n let h = total.div(3600)\n let m = (total % 3600).div(60)\n let s = total % 60\n return f\"{h:02d}:{m:02d}:{s:02d}\"\n}\nprint(formatSeconds(3665), formatSeconds(72))"}],"meta":{"output":"01:01:05 00:01:12"}} {"messages":[{"role":"user","content":"Write a Mycel program implementing a state machine with Idle, Processing, and Done states."},{"role":"assistant","content":"enum State { Idle, Processing(step: Int), Done }\nclass Worker {\n var state: State = .Idle\n fn step() {\n self.state = match self.state {\n .Idle => .Processing(step: 1)\n .Processing(s) => if s >= 2 { .Done } else { .Processing(step: s + 1) }\n .Done => .Done\n }\n }\n}\nlet w = Worker()\nw.step()\nprint(match w.state { .Processing(s) => f\"Step {s}\", _ => \"Other\" })\nw.step()\nprint(match w.state { .Done => \"Finished!\", _ => \"Running\" })"}],"meta":{"output":"Step 1\nRunning"}} {"messages":[{"role":"user","content":"Write a Mycel program rotating a list to the left by k positions."},{"role":"assistant","content":"fn rotateLeft(items: [T], k: Int) -> [T] {\n let shift = k % items.length\n return items.slice(shift, items.length).concat(items.slice(0, shift))\n}\nprint(rotateLeft([1, 2, 3, 4, 5], 2))"}],"meta":{"output":"[3, 4, 5, 1, 2]"}} {"messages":[{"role":"user","content":"Write a Mycel program that generates an ASCII bar chart for a list of values."},{"role":"assistant","content":"let data = [(\"Apples\", 5), (\"Oranges\", 8), (\"Bananas\", 3)]\nfor item in data {\n let bar = \"#\".repeat(item.1)\n print(f\"{item.0.padRight(8)} | {bar} ({item.1})\")\n}"}],"meta":{"output":"Apples | ##### (5)\nOranges | ######## (8)\nBananas | ### (3)"}} {"messages":[{"role":"user","content":"Write a Mycel program finding the mode (most frequent element) of an integer array."},{"role":"assistant","content":"fn findMode(nums: [Int]) -> Int {\n var freq: {Int: Int} = {}\n for n in nums { freq[n] = freq.get(n, 0) + 1 }\n var bestNum = nums[0]\n var maxCount = 0\n for n, count in freq {\n if count > maxCount {\n maxCount = count\n bestNum = n\n }\n }\n return bestNum\n}\nprint(findMode([1, 3, 2, 3, 4, 3, 2, 1]))"}],"meta":{"output":"3"}} {"messages":[{"role":"user","content":"Write a Mycel program that checks if a string contains balanced parentheses."},{"role":"assistant","content":"fn isBalanced(s: String) -> Bool {\n var count = 0\n for ch in s {\n if ch == '(' { count += 1 }\n else if ch == ')' {\n count -= 1\n if count < 0 { return false }\n }\n }\n return count == 0\n}\nprint(isBalanced(\"((1+2)*3)\"), isBalanced(\"(()\"), isBalanced(\")(\"))"}],"meta":{"output":"true false false"}} {"messages":[{"role":"user","content":"Write a Mycel program calculating cumulative sum of an integer array."},{"role":"assistant","content":"fn cumSum(nums: [Int]) -> [Int] {\n var res: [Int] = []\n var running = 0\n for n in nums {\n running += n\n res.push(running)\n }\n return res\n}\nprint(cumSum([1, 2, 3, 4, 5]))"}],"meta":{"output":"[1, 3, 6, 10, 15]"}} {"messages":[{"role":"user","content":"Write a Mycel program implementing Matrix Addition."},{"role":"assistant","content":"fn matrixAdd(m1: [[Int]], m2: [[Int]]) -> [[Int]] {\n var res: [[Int]] = []\n for r in 0..m1.length {\n var row: [Int] = []\n for c in 0..m1[r].length {\n row.push(m1[r][c] + m2[r][c])\n }\n res.push(row)\n }\n return res\n}\nprint(matrixAdd([[1, 2], [3, 4]], [[5, 6], [7, 8]]))"}],"meta":{"output":"[[6, 8], [10, 12]]"}} {"messages":[{"role":"user","content":"Write a Mycel program testing bitwise AND, OR, XOR, and shifts on integers."},{"role":"assistant","content":"let a = 12 // 0b1100\nlet b = 10 // 0b1010\nprint(a & b, a | b, a ^ b, 1 << 3, 16 >> 2)"}],"meta":{"output":"8 14 6 8 4"}} {"messages":[{"role":"user","content":"Write a Mycel program that safely retrieves an array item with index out-of-bounds protection."},{"role":"assistant","content":"fn safeGet(arr: [T], idx: Int, fallback: T) -> T {\n return arr.at(idx) ?? fallback\n}\nprint(safeGet([\"a\", \"b\"], 1, \"none\"), safeGet([\"a\", \"b\"], 5, \"none\"))"}],"meta":{"output":"b none"}}