<commit_before>package main

import (
    "bufio"
    "fmt"
    "os"
    "strings"
    "unicode"
    "strconv"
    "math"
    "errors"
    "./functions"
)

func main() {
    fmt.Print("> ")
    scanner := bufio.NewScanner(os.Stdin)
    for scanner.Scan() {
        text := scanner.Text()
        fmt.Printf("%s\n", strconv.FormatFloat(parens(text), 'G', -1, 64))
        fmt.Print("> ")
    }
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("3*(3-(5+6)^12)*23^3-5^23"), 'G', -1, 64))
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("2^2^3^2"), 'G', -1, 64))
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("-3^2"), 'G', -1, 64))
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("2(1+1)4"), 'G', -1, 64))
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("1+2sin(-1024)tan(acos(1))^2"), 'G', -1, 64))
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("lg(log(1e16))"), 'G', -1, 64))
}

func parens(exp string) float64 {
    for i := 0; i < len(exp); i++ {
        if exp[i] == '(' {
            var inner string
            var j int
            open := 1
            for j = i+1; open > 0; j++ {
                if exp[j] == ')' {
                    open--
                } else if exp[j] == '(' {
                    open++
                }
                inner += string(exp[j])
            }
            res := parens(inner[:len(inner)-1])
            insert := strconv.FormatFloat(res, 'f', -1, 64)

            if i > 0 && unicode.IsNumber(rune(exp[i-1])) {<commit_msg>Compute expression as an argument<commit_after>package main

import (
    "bufio"
    "fmt"
    "os"
    "strings"
    "unicode"
    "strconv"
    "math"
    "errors"
    "./functions"
)

func main() {
    if len(os.Args) > 1 {
        input := strings.Replace(strings.Join(os.Args[1:], ""), " ", "", -1)
        fmt.Printf("%s\n", strconv.FormatFloat(parens(input), 'G', -1, 64))
        return
    }

    fmt.Print("> ")
    scanner := bufio.NewScanner(os.Stdin)
    for scanner.Scan() {
        text := strings.Replace(scanner.Text(), " ", "", -1)

        if text == "exit" || text == "quit" {
            return
        }

        fmt.Printf("%s\n", strconv.FormatFloat(parens(text), 'G', -1, 64))
        fmt.Print("> ")
    }
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("3*(3-(5+6)^12)*23^3-5^23"), 'G', -1, 64))
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("2^2^3^2"), 'G', -1, 64))
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("-3^2"), 'G', -1, 64))
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("2(1+1)4"), 'G', -1, 64))
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("1+2sin(-1024)tan(acos(1))^2"), 'G', -1, 64))
    // fmt.Printf("%s\n", strconv.FormatFloat(parens("lg(log(1e16))"), 'G', -1, 64))
}

func parens(exp string) float64 {
    for i := 0; i < len(exp); i++ {
        if exp[i] == '(' {
            var inner string
            var j int
            open := 1
            for j = i+1; open > 0; j++ {
                if exp[j] == ')' {
                    open--
                } else if exp[j] == '(' {
                    open++
                }
                inner += string(exp[j])
            }
            res := parens(inner[:len(inner)-1])
            insert := strconv.FormatFloat(res, 'f', -1, 64)

            if i > 0 && unicode.IsNumber(rune(exp[i-1])) {
{'fraction_non_alphanumeric': 0.22525494901019796, 'fraction_numerical': 0.04169166166766647, 'mean_word_length': 1.8949652777777777, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3758290', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1246, 'n_words': 229}