This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun help () = print "Run me as: \n\tpoly -q --use foo.sml --eval 'val _ = main ()'\n" | |
| fun main () = (TextIO.output (TextIO.stdErr, "ZOMG!"); OS.Process.exit OS.Process.success) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // count occurrences of the same combination of characters in an array of strings | |
| // example: | |
| // > console.log(count(['ab', 'ba'])) | |
| // [2] | |
| const xs = [ 'aba', 'aab', 'ccc', 'ddc', 'dcd', 'baa', 'dds', 'sdd', 'dcd', 'xyz' ]; | |
| const count = xs => { | |
| const map = xs.reduce((acc, x) => { | |
| const key = Array.from(new Set(x)).sort().join(''); | |
| return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "sort" | |
| "golang.org/x/tour/tree" | |
| ) | |
| // Walk walks the tree t sending all values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def max_difference(xs): | |
| max = min = xs[0] | |
| d = -1 | |
| for x in xs[1:]: | |
| if min > x: | |
| min = max = x | |
| continue | |
| if x > max: | |
| max = x | |
| if max - min > d: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun fizzbuzz' n = | |
| case (n mod 5 = 0, n mod 3 = 0) of | |
| (true, true) => "FizzBuzz" | |
| | (true, false) => "Buzz" | |
| | (false, true) => "Fizz" | |
| | _ => Int.toString n | |
| fun fizzbuzz n = | |
| let | |
| fun loop m = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (|>) :: a -> (a -> b) -> b | |
| x |> f = f x | |
| [1..6] |> sum | |
| inc = (+) 1 | |
| [1..5] |> map inc |> sum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const findLastRowWithValue = (sheet) => { | |
| const { decode_cell } = XLSX.utils; | |
| const { r } = decode_cell(sheet['!ref'].split(':')[1]); | |
| const isEmpty = (x) => sheet[`A${ x }`].v === undefined; | |
| let start = 1; | |
| let end = r + 1; | |
| let pivot = Math.round((end - start) / 2); | |
| if (pivot === 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| do { | |
| if (!this.isQuotePublished()) { | |
| <div> | |
| <Dialog ref="modalDeleteQuoteDraft" type="modal"> | |
| <DialogOverlay> | |
| <DialogHeader> | |
| <DialogTitle>{ t('QUOTE_DRAFT_DELETE') }</DialogTitle> | |
| </DialogHeader> | |
| <p style={ { padding: 20 } }> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function nameList(ParamArray xs() As Variant) As String | |
| For i = LBound(xs) To UBound(xs) | |
| For Each x In xs(i).Cells | |
| If x.value <> "" Then | |
| If nameList <> "" Then | |
| nameList = nameList & ", " | |
| End If | |
| nameList = nameList & x.value | |
| End If | |
| Next x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function* fib() { | |
| let a = 0; | |
| let b = 1; | |
| while (true) { | |
| [a, b] = [b, a + b]; | |
| yield a; | |
| } | |
| } | |
| const sleep = async (n) => await (new Promise(r => setTimeout(r, n))); |