Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ msbuild.wrn

# Boba repo custom
output/*
main.go
docs.md
natUnit*.go
boba.exe
41 changes: 0 additions & 41 deletions Boba.Core/Abelian.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,6 @@ module Abelian =

member this.IsConstant () = this.Variables.IsEmpty

/// Get the exponent of the given variable name within this equation. Returns 0 if the variable is not present.
member this.ExponentOf var =
if this.Variables.ContainsKey(var)
then this.Variables.[var]
else 0

/// Determines whether all exponents in the equation are integer multiples of the given divisor.
member this.DividesPowers divisor =
let divides k pow = pow % divisor = 0
Map.forall divides this.Variables && Map.forall divides this.Constants

/// For a given variable, returns whether there is another variable in the equation that has a higher exponent.
member this.NotMax var =
let examined = this.ExponentOf var |> abs
let varHasGreaterExponent k v = k <> var && abs v >= examined
Map.exists varHasGreaterExponent this.Variables

/// Negates each exponent in the equation.
member this.Invert () =
new Equation<'a, 'b>(mapValues (( ~- )) this.Variables, mapValues (( ~- )) this.Constants)
Expand All @@ -61,32 +44,8 @@ module Abelian =
/// Removes the given equation from this Abelian unit equation. Equivalent to `this.Add(other.Invert())`.
member this.Subtract (other: Equation<'a, 'b>) = other.Invert() |> this.Add;

/// Multiplies each exponent in the unit equation by the given factor.
member this.Scale (factor: int) =
let scale v = v * factor
new Equation<'a, 'b>(mapValues scale this.Variables, mapValues scale this.Constants)

/// Divides each exponent in the unit equation by the given factor.
member this.Divide (factor: int) =
let scale v = v / factor
new Equation<'a, 'b>(mapValues scale this.Variables, mapValues scale this.Constants)

/// Removes the specified variable from the unit, and divides all other powers by the removed variable's power.
member this.Pivot (var: 'a) =
let pivotPower = this.ExponentOf var
let inverse = new Equation<'a, 'b>(var)
this.Subtract(inverse.Scale(pivotPower))
.Divide(pivotPower)
.Invert();

// Get the free variables of this equation.
member this.Free () = mapKeys this.Variables

/// Substitutes the given equation for the specified variable, applying the variable's power to the substituted unit.
member this.Substitute (name: 'a) (other: Equation<'a, 'b>) =
other.Subtract(new Equation<'a, 'b>(name))
.Scale(this.ExponentOf(name))
.Add(this);

member this.FractionString () =
let expToStr exps =
Expand Down
39 changes: 39 additions & 0 deletions cmd/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright © 2023 Glossopoeia
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// buildCmd represents the build command
var buildCmd = &cobra.Command{
Use: "build",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("build called")
},
}

func init() {
rootCmd.AddCommand(buildCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// buildCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// buildCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
39 changes: 39 additions & 0 deletions cmd/clean.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright © 2023 Glossopoeia
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// cleanCmd represents the clean command
var cleanCmd = &cobra.Command{
Use: "clean",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("clean called")
},
}

func init() {
rootCmd.AddCommand(cleanCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// cleanCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// cleanCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
39 changes: 39 additions & 0 deletions cmd/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright © 2023 Glossopoeia
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// docsCmd represents the docs command
var docsCmd = &cobra.Command{
Use: "docs",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("docs called")
},
}

func init() {
rootCmd.AddCommand(docsCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// docsCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// docsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
39 changes: 39 additions & 0 deletions cmd/format.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright © 2023 Glossopoeia
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// formatCmd represents the format command
var formatCmd = &cobra.Command{
Use: "format",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("format called")
},
}

func init() {
rootCmd.AddCommand(formatCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// formatCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// formatCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
39 changes: 39 additions & 0 deletions cmd/info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright © 2023 Glossopoeia
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// infoCmd represents the info command
var infoCmd = &cobra.Command{
Use: "info",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("info called")
},
}

func init() {
rootCmd.AddCommand(infoCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// infoCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// infoCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
39 changes: 39 additions & 0 deletions cmd/publish.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright © 2023 Glossopoeia
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// publishCmd represents the publish command
var publishCmd = &cobra.Command{
Use: "publish",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("publish called")
},
}

func init() {
rootCmd.AddCommand(publishCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// publishCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// publishCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
46 changes: 46 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Copyright © 2023 Glossopoeia
*/
package cmd

import (
"os"

"github.com/spf13/cobra"
)

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "boba",
Short: "A brief description of your application",
Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}

func init() {
// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.

// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.boba.yaml)")

// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
39 changes: 39 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright © 2023 Glossopoeia
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// runCmd represents the run command
var runCmd = &cobra.Command{
Use: "run",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("run called")
},
}

func init() {
rootCmd.AddCommand(runCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// runCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// runCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
Loading