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
| let extract_record_computational_axioms (ctx : LinkageCtx.t) : Libnames.qualid list = | |
| let rec collect (prefix : Libnames.qualid option) (linkage : Linkage.t) | |
| (acc : Libnames.qualid list) : Libnames.qualid list = | |
| let rec walk fields acc = | |
| match fields with | |
| | Bwd.Emp -> acc | |
| | Bwd.Snoc (rest, (field_name, elem)) -> | |
| let acc = walk rest acc in | |
| match elem with | |
| | LinkageElem.RecordComputationalAxiom { name; _ } -> |
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
| let long_computation () = | |
| for i = 0 to 1_000_000_000 do | |
| () | |
| done | |
| (* No parallelism *) | |
| (* | |
| ________________________________________________________ | |
| Executed in 36.09 secs fish external | |
| usr time 36.08 secs 1.27 millis 36.08 secs |
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
| type stack = int array | |
| type machine = { ip : int; sp : int; mutable stack : stack } | |
| (* Machine stack *) | |
| module type S = sig | |
| type t | |
| type index | |
| type elem |
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
| (* camel_to_kebab('CamelCaseString') == 'camel-case-string' | |
| camel_to_kebab('CamelCaseStringWithABREV') == 'camel-case-string-with-abrev' | |
| camel_to_kebab('CamelCaseStringWithABREVInCenter') == 'camel-case-string-with-abrev-in-center' *) | |
| (* words = re.findall('([A-Z][a-z]+)|([A-Z]+(?=[A-Z][a-z]+))', s) *) | |
| type state = | |
| | Start | |
| | InsideCamel | |
| | InsideAbrev |
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
| let (next, _) = linearization.get_items_adjacent(parent.id); | |
| let next = next.and_then(|item| match item.kind { | |
| TermKind::RecordField { | |
| ident, | |
| record, | |
| value: ValueState::Known(value), | |
| .. | |
| } if value == parent.id => Some((ident, record)), | |
| _ => None, | |
| }); |
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
| let path: String = path.chars().skip_while(|ch| !(ch.is_alphanumeric() || *ch == '-' || *ch == '_')).collect(); | |
| // | |
| // ("Paren before ident", "(record", vec!["record"]) |
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
| fn parse_crate<'a, I>(chs: &'a mut I) -> Option<char> | |
| where | |
| I: Iterator<Item = char>, | |
| { | |
| fn is_for_crate<'a, I>(c: char, chs: &'a mut I) -> bool | |
| where | |
| I: Iterator<Item = char>, | |
| { | |
| if c == '[' || c == ']' { | |
| true |
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
| let mut file = std::fs::OpenOptions::new() | |
| .write(true) | |
| .append(false) | |
| .create(true) | |
| .open("/home/ebresafegaga/server.log") | |
| .unwrap(); | |
| let data = format!("{:?}", linearization.linearization); | |
| std::io::Write::write(&mut file, data.as_ref()).unwrap(); |
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
| fn calculate_offset(c: u32, l: u32, t: &String) -> usize { | |
| let (c, l) = (c as usize, l as usize); | |
| // Line is 0 indexed so we don't need to skip the | |
| // line that the cursor is currently on. | |
| // It will be done automatically during the `take`, because | |
| // of the 0 index. | |
| let count = t | |
| .split('\n') | |
| .take(l) | |
| .collect::<Vec<_>>() |
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
| fn sort<const N: usize>(arr: [i32; N]) -> Vec<i32> { | |
| let mut max = arr[0]; | |
| // Find the max of the array | |
| for i in 0..arr.len() { | |
| if arr[i] > max { | |
| max = arr[i] | |
| } | |
| } |
NewerOlder