Fuzion Logo
flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

Idioms

These are examples taken from programming-idioms.org and ported to Fuzion:

Programming Idioms

Idiom # 1: Print Hello World
Idiom # 2: Print Hello 10 times
Idiom # 3: Create a procedure
Idiom # 4: Create a function which returns the square of an integer
Idiom # 5: Create a 2D Point data structure
Idiom # 6: Iterate over list values
Idiom # 7: Iterate over list indexes and values
Idiom # 8: Initialize a new map (associative array)
Idiom # 9: Create a Binary Tree data structure
NYI: Idiom # 10: Shuffle a list
NYI: Idiom # 11: Pick a random element from a list
Idiom # 12: Check if list contains a value
Idiom # 13: Iterate over map keys and values
NYI: Idiom # 14: Pick uniformly a random floating point number in [a..b)
NYI: Idiom # 15: Pick uniformly a random integer in [a..b]
Idiom # 16: Depth-first traversing of a binary tree
Idiom # 17: Create a Tree data structure
Idiom # 18: Depth-first traversing of a tree
Idiom # 19: Reverse a list
Idiom # 20: Return two values
Idiom # 21: Swap values
Idiom # 22: Convert string to integer
NYI: Idiom # 23: Convert real number to string with 2 decimal places
Idiom # 24: Assign to string the japanese word ネコ
NYI: Idiom # 25: Send a value to another thread
Idiom # 26: Create a 2-dimensional array
Idiom # 27: Create a 3-dimensional array
Idiom # 28: Sort by a property
Idiom # 29: Remove item from list, by its index
NYI: Idiom # 30: Parallelize execution of 1000 independent tasks
Idiom # 31: Recursive factorial (simple)
Idiom # 32: Integer exponentiation by squaring
NYI: Idiom # 33: Atomically read and update variable
Idiom # 34: Create a Set of objects
Idiom # 35: First-class function : compose
Idiom # 36: First-class function : generic composition
Idiom # 37: Currying
Idiom # 38: Extract a substring
Idiom # 39: Check if string contains a word
Idiom # 40: Graph with adjacency lists
Idiom # 41: Reverse a string
Idiom # 42: Continue outer loop
Idiom # 43: Break outer loop
Idiom # 44: Insert element in list
NYI: Idiom # 45: Pause execution for 5 seconds
Idiom # 46: Extract beginning of string (prefix)
Idiom # 47: Extract string suffix
Idiom # 48: Multi-line string literal
Idiom # 49: Split a space-separated string
Idiom # 50: Make an infinite loop
Idiom # 51: Check if map contains key
Idiom # 52: Check if map contains value
Idiom # 53: Join a list of strings
Idiom # 54: Compute sum of integers
Idiom # 55: Convert integer to string
NYI: Idiom # 56: Launch 1000 parallel tasks and wait for completion
Idiom # 57: Filter list
NYI: Idiom # 58: Extract file content to a string
NYI: Idiom # 59: Write to standard error stream
NYI: Idiom # 60: Read command line argument
NYI: Idiom # 61: Get current date
Idiom # 62: Find substring position
Idiom # 63: Replace fragment of a string
NYI: Idiom # 64: Big integer : value 3 power 247
NYI: Idiom # 65: Format decimal number
NYI: Idiom # 66: Big integer exponentiation
NYI: Idiom # 67: Binomial coefficient n choose k
Idiom # 68: Create a bitset
NYI: Idiom # 69: Seed random generator
NYI: Idiom # 70: Use clock as random generator seed
NYI: Idiom # 71: Echo program implementation
NYI: Idiom # 73: Create a factory
NYI: Idiom # 74: Compute GCD
NYI: Idiom # 75: Compute LCM
Idiom # 76: Binary digits from an integer
Idiom # 77: Complex number
Idiom # 78: do while loop
NYI: Idiom # 79: Convert integer to floating point number
NYI: Idiom # 80: Truncate floating point number to integer
NYI: Idiom # 81: Round floating point number to integer
Idiom # 82: Count substring occurrences
NYI: Idiom # 83: Regex with character repetition
Idiom # 84: Count bits set in integer binary representation
Idiom # 85: Check if integer addition will overflow
Idiom # 86: Check if integer multiplication will overflow
Idiom # 87: Stop program
Idiom # 88: Allocate 1M bytes
Idiom # 89: Handle invalid argument
Idiom # 90: Read-only outside
NYI: Idiom # 91: Load JSON file into struct
NYI: Idiom # 92: Save object into JSON file
Idiom # 93: Pass a runnable procedure as parameter
NYI: Idiom # 94: Print type of variable
NYI: Idiom # 95: Get file size
Idiom # 96: Check string prefix
Idiom # 97: Check string suffix
NYI: Idiom # 98: Epoch seconds to date object
NYI: Idiom # 99: Format date YYYY-MM-DD
Idiom # 100: Sort by a comparator
NYI: Idiom # 101: Load from HTTP GET request into a string
NYI: Idiom # 102: Load from HTTP GET request into a file
NYI: Idiom # 103: Load XML file into struct
NYI: Idiom # 104: Save object into XML file
NYI: Idiom # 105: Current executable name
NYI: Idiom # 106: Get program working directory
NYI: Idiom # 107: Get folder containing current program
Idiom # 108: Determine if variable name is defined
NYI: Idiom # 109: Number of bytes of a type
Idiom # 110: Check if string is blank
NYI: Idiom # 111: Launch other program
Idiom # 112: Iterate over map entries, ordered by keys
Idiom # 113: Iterate over map entries, ordered by values
Idiom # 114: Test deep equality
NYI: Idiom # 115: Compare dates
Idiom # 116: Remove occurrences of word from string
Idiom # 117: Get list size
Idiom # 118: List to set
Idiom # 119: Deduplicate list
NYI: Idiom # 120: Read integer from stdin
NYI: Idiom # 121: UDP listen and read
Idiom # 122: Declare enumeration
NYI: Idiom # 123: Assert condition
Idiom # 124: Binary search for a value in sorted array
NYI: Idiom # 125: Measure function call duration
Idiom # 126: Multiple return values
Idiom # 127: Source code inclusion
NYI: Idiom # 128: Breadth-first traversing of a tree
NYI: Idiom # 129: Breadth-first traversing in a graph
NYI: Idiom # 130: Depth-first traversing in a graph
Idiom # 131: Successive conditions
NYI: Idiom # 132: Measure duration of procedure execution
NYI: Idiom # 133: Case-insensitive string contains
Idiom # 134: Create a new list
Idiom # 135: Remove item from list, by its value
Idiom # 136: Remove all occurrences of a value from a list
Idiom # 137: Check if string contains only digits
NYI: Idiom # 138: Create temp file
NYI: Idiom # 139: Create temp directory
NYI: Idiom # 140: Delete map entry
Idiom # 141: Iterate in sequence over two lists
Idiom # 142: Hexadecimal digits of an integer
Idiom # 143: Iterate alternatively over two lists
NYI: Idiom # 144: Check if file exists
NYI: Idiom # 145: Print log line with datetime
NYI: Idiom # 146: Convert string to floating point number
Idiom # 147: Remove all non-ASCII characters
NYI: Idiom # 148: Read list of integer numbers from stdin
NYI: Idiom # 149: Rescue the princess
Idiom # 150: Remove trailing slash
NYI: Idiom # 151: Remove string trailing path separator
Idiom # 152: Turn a character into a string
Idiom # 153: Concatenate string with integer
Idiom # 154: Halfway between two hex color codes
NYI: Idiom # 155: Delete file
Idiom # 156: Format integer with zero-padding
Idiom # 157: Declare constant string
NYI: Idiom # 158: Random sublist
Idiom # 159: Trie
NYI: Idiom # 160: Detect if 32-bit or 64-bit architecture
Idiom # 161: Multiply all the elements of a list
NYI: Idiom # 162: Execute procedures depending on options
Idiom # 163: Print list elements by group of 2
NYI: Idiom # 164: Open URL in default browser
Idiom # 165: Last element of list
Idiom # 166: Concatenate two lists
Idiom # 167: Trim prefix
Idiom # 168: Trim suffix
Idiom # 169: String length
Idiom # 170: Get map size
Idiom # 171: Add an element at the end of a list
Idiom # 172: Insert entry in map
NYI: Idiom # 173: Format a number with grouped thousands
NYI: Idiom # 174: Make HTTP POST request
Idiom # 175: Bytes to hex string
Idiom # 176: Hex string to byte array
NYI: Idiom # 177: Find files with a given list of filename extensions
Idiom # 178: Check if point is inside rectangle
Idiom # 179: Get center of a rectangle
NYI: Idiom # 180: List files in directory
Idiom # 182: Quine program
NYI: Idiom # 183: Make HTTP PUT request
NYI: Idiom # 184: Tomorrow
NYI: Idiom # 185: Execute function in 30 seconds
Idiom # 186: Exit program cleanly
Idiom # 187: Disjoint Set
Idiom # 188: Matrix multiplication
Idiom # 189: Filter and transform list
NYI: Idiom # 190: Call an external C function
Idiom # 191: Check if any value in a list is larger than a limit
NYI: Idiom # 192: Declare a real variable with at least 20 digits
Idiom # 193: Transpose a two-dimensional matrix
Idiom # 194: Circular shift of a two-dimensional array
Idiom # 195: Pass a two-dimensional array
Idiom # 196: Pass a sub-array
NYI: Idiom # 197: Get a list of lines from a file
Idiom # 198: Abort program execution with error condition
NYI: Idiom # 199: Truncate a file at the current file position
NYI: Idiom # 200: Return hypotenuse
NYI: Idiom # 201: Euclidean norm
Idiom # 202: Sum of squares
Idiom # 203: Calculate mean and standard deviation
NYI: Idiom # 204: Return fraction and exponent of a real number
NYI: Idiom # 205: Get an environment variable
Idiom # 206: Switch statement with strings
Idiom # 207: allocate a list that is automatically deallocated
Idiom # 208: Formula with arrays
Idiom # 209: Type with automatic deep deallocation
NYI: Idiom # 210: Compiler version and options
NYI: Idiom # 211: Create folder
NYI: Idiom # 212: Check if folder exists
NYI: Idiom # 213: Case-insensitive string compare
Idiom # 214: Pad string on the right
Idiom # 215: Pad string on the left
Idiom # 216: Pad a string in the center
NYI: Idiom # 217: Create a Zip archive
Idiom # 218: List intersection
Idiom # 219: Replace multiple spaces with single space
Idiom # 220: Create a tuple value
Idiom # 221: Remove all non-digits characters
Idiom # 222: Find first index of an element in list
Idiom # 223: for else loop
Idiom # 224: Add element to the beginning of the list
Idiom # 225: Declare and use an optional argument
Idiom # 226: Delete last element from list
Idiom # 227: Copy list
NYI: Idiom # 228: Copy a file
NYI: Idiom # 229: Cancel an operation
NYI: Idiom # 230: Timeout
Idiom # 231: Test if bytes are a valid UTF-8 string
NYI: Idiom # 232: Read a command line boolean flag
NYI: Idiom # 233: Read a command line string flag
NYI: Idiom # 234: Encode bytes to base64
NYI: Idiom # 235: Decode base64
NYI: Idiom # 236: Large quotient
Idiom # 237: Xor integers
Idiom # 238: Xor byte arrays
NYI: Idiom # 239: Find first regular expression match
Idiom # 240: Sort 2 lists together
NYI: Idiom # 241: Yield priority to other threads
Idiom # 242: Iterate over a set
Idiom # 243: Print list
Idiom # 244: Print map
Idiom # 245: Print value of custom type
Idiom # 246: Count distinct elements
Idiom # 247: Filter list in-place
NYI: Idiom # 248: Construct a 64-bit floating-point value
Idiom # 249: Declare and assign multiple variables
NYI: Idiom # 250: Pick a random value from a map
Idiom # 251: Parse binary digits
Idiom # 252: Conditional assignment
NYI: Idiom # 253: Print stack trace
Idiom # 254: Replace value in list
Idiom # 255: Print set
Idiom # 256: Count backwards
Idiom # 257: Traverse list backwards
Idiom # 258: Convert list of strings to list of integers
NYI: Idiom # 259: Split on several separators
NYI: Idiom # 260: Create an empty list of strings
NYI: Idiom # 261: Format time hours-minutes-seconds
NYI: Idiom # 262: Count trailing zero bits
NYI: Idiom # 263: Integer logarithm in base 2
NYI: Idiom # 264: Automated passing of array bounds
NYI: Idiom # 265: Calculate parity of an integer
NYI: Idiom # 266: Repeating string
NYI: Idiom # 267: Pass string to argument that can be of any type
NYI: Idiom # 268: User-defined operator
NYI: Idiom # 269: Enum to String
NYI: Idiom # 270: Test for quiet or signalling NaN
NYI: Idiom # 271: Test for type extension
NYI: Idiom # 272: Play FizzBuzz
NYI: Idiom # 273: Check if folder is empty
NYI: Idiom # 274: Remove all white space characters
NYI: Idiom # 275: Binary digits to byte array
NYI: Idiom # 276: Insert an element in a set
NYI: Idiom # 277: Remove an element from a set