-
Notifications
You must be signed in to change notification settings - Fork 0
Rewrote the LaTeX parser to be more flexible #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Happypig375
wants to merge
18
commits into
master
Choose a base branch
from
LaTeX-Rewrite
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
69bc573
Started a LaTeX code rewrite
Happypig375 c22da95
Still not buildable yet...
Happypig375 c92ea5b
More arguments that can now be replaced
Happypig375 da0d631
Actual progress!!!
Happypig375 37f5512
Buildable again...!
Happypig375 ca21278
\frac23 successful
Happypig375 f3d011d
LaTeX Rewrite - commit!
Happypig375 3d3702b
Remove unused functions
Happypig375 3867c0a
Simplification
Happypig375 4356592
Added \left and \right
Happypig375 85ce106
documented and simplified AliasDictionary
bd84e27
finish tidying AliasDictionary
9640f15
finish tidy of AliasDictionary
acae974
rename collapseRow
efc8bef
tidy
dc67af6
add Aliases property to AliasDictionary
4004ec9
Simplified AliasDictionary
Happypig375 8fa8bd2
[WIP] Working on FromAtom
Happypig375 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| namespace MathDisplay.DataTypes | ||
|
|
||
| open System.Collections.Generic | ||
|
|
||
| /// Holds a d:Dictionary<'X,'Y>, and an e:Dictionary<'Y,'X> which are quasi-inverses in the sense that | ||
| /// for any key x in d, x.[d] is key in 'Y, and d.[e.[y]] = y. | ||
| /// d-keys are "Aliases" of e-keys, and a e-key may have many aliases mapping to it (so d may not be injective), | ||
| /// but there is a primary alias corresponding to each e-key (so e is injective). | ||
| type AliasDictionary<'X, 'Y when 'X : equality and 'Y : equality> private(d:Dictionary<'X,'Y>, e:Dictionary<'Y,'X>) = | ||
| new() = AliasDictionary(Dictionary<'X, 'Y>(), Dictionary<'Y, 'X>()) | ||
| member __.Aliases = d.Keys | ||
| /// Add primary aliases | ||
| member __.AddPrimary(primaryAlias:'X, value:'Y) = | ||
| d.Add(primaryAlias, value) | ||
| e.Add(value, primaryAlias) | ||
| /// Add secondary aliases | ||
| member __.AddMore(secondaryAliases:seq<'X>, value:'Y) = | ||
| for x in secondaryAliases do d.Add(x, value) | ||
| member this.Add(primaryAlias:'X, secondaryAliases : seq<'X>, value:'Y) = | ||
| d.Add(primaryAlias, value) | ||
| e.Add(value, primaryAlias) | ||
| this.AddMore(secondaryAliases, value) | ||
| /// The first item of aliases is primary. | ||
| member this.Add(aliases : 'X list, value:'Y) = | ||
| match aliases with | ||
| | primaryAlias::secondaryAliases -> | ||
| d.Add(primaryAlias, value) | ||
| e.Add(value, primaryAlias) | ||
| this.AddMore(secondaryAliases, value) | ||
| | [] -> () | ||
| /// The first of any 'X list is primary. | ||
| member this.AddList(pairs:('X list * 'Y) list) = | ||
| pairs |> List.iter (fun (keys, value) -> | ||
| match keys with | ||
| | primaryKey::secondaryKeys -> | ||
| this.Add(primaryKey, secondaryKeys, value) | ||
| | [] -> ()) | ||
| /// The first of any 'X list is primary. | ||
| new(pairs:('X list * 'Y) list) as this = | ||
| AliasDictionary<'X, 'Y>() then | ||
| this.AddList pairs | ||
| /// The first of any 'X list is primary. | ||
| new(valueComparer:IEqualityComparer<'Y>, pairs:('X list * 'Y) list) as this = | ||
| AliasDictionary<'X, 'Y>(Dictionary<'X, 'Y>(), Dictionary<'Y, 'X>(valueComparer)) then | ||
| this.AddList pairs | ||
| member __.TryGetKey value = | ||
| match e.TryGetValue value with | ||
| | true, v -> ValueSome v | ||
| | false, _ -> ValueNone | ||
| member __.TryGetValue key = | ||
| match d.TryGetValue key with | ||
| | true, v -> ValueSome v | ||
| | false, _ -> ValueNone |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,18 @@ module MathDisplay.DataTypes.List | |
| /// Partition elements of a list using the specified predicate. | ||
| /// The result is a tuple containing elements (from the beginning | ||
| /// of the list that satisfy the predicate) and the rest of the list. | ||
| let inline partitionWhile f = | ||
| let partitionWhile (f: 'T -> bool) = | ||
| let rec loop acc = function | ||
| | x::xs when f x -> loop (x::acc) xs | ||
| | xs -> List.rev acc, xs | ||
| loop [] | ||
| loop [] | ||
|
|
||
| // TODO: What is this? Simplify type signature and document, or remove | ||
| let mapFoldResult f (state:'State) (list: 'T list) : Result<'Result list * 'State, 'Error> = | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs XML comment. |
||
| let rec loop acc state = function | ||
| | [] -> (List.rev acc, state) |> Ok | ||
| | x::xs -> | ||
| match f state x with | ||
| | Ok (value, state) -> loop (value::acc) state xs | ||
| | Error e -> Error e | ||
| loop [] state list | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.