<commit_before>﻿module Naggum.Runtime

open System
open Types
open Context

let add = fun (sexp) ->
            let args = List.map (fun (x) ->
                                    match x with
                                    |Atom (Number n) -> n
                                    |any ->
                                        eprintfn "Expected: Number\nGot: %A" any
                                        raise (new ArgumentException()))
                                (match sexp with
                                    | List xs -> xs
                                    | Atom a -> [Atom a]
                                    | Quote q -> 
                                        eprintfn "Expected: Number\nGot: Quote %A" q
                                        raise (new ArgumentException()))
            List.reduce (+) args |> Number |> Atom

let sub = fun (sexp) ->
            let args = List.map (fun (x) ->
                                    match x with
                                    |Atom (Number n) -> n
                                    |any ->
                                        eprintfn "Expected: Number\nGot: %A" any
                                        raise (new ArgumentException()))
                                (match sexp with
                                    | List xs -> xs
                                    | Atom a -> [Atom a]
                                    | Quote q -> 
                                        eprintfn "Expected: Number\nGot: Quote %A" q
                                        raise (new ArgumentException()))
            List.reduce (-) args |> Number |> Atom

let mul = fun (sexp) ->
            let args = List.map (fun (x) ->
                                    match x with
                                    |Atom (Number n) -> n
                                    |any ->
                                        eprintfn "Expected: Number\nGot: %A" any
                                        raise (new ArgumentException()))
                                (match sexp with
                                    | List xs -> xs
                                    | Atom a -> [Atom a]
                                    | Quote q -> 
                                        eprintfn "Expected: Number\nGot: Quote %A" q
                                        raise (new ArgumentException()))
            List.reduce (*) args |> Number |> Atom

let div = fun (sexp) ->
            let args = List.map (fun (x) ->
                                    match x with
                                    |Atom (Number n) -> n
                                    |any ->
                                        eprintfn "Expected: Number\nGot: %A" any
                                        raise (new ArgumentException()))
                                (match sexp with
                                    | List xs -> xs
                                    | Atom a -> [Atom a]
                                    | Quote q -> 
                                        eprintfn "Expected: Number\nGot: Quote %A" q
                                        raise (new ArgumentException()))
            List.reduce (/) args |> Number |> Atom

let equal = fun (sexp) ->
            let args =
                (match sexp with
                 | List xs -> xs
                 | Atom a -> [Atom a]
                 | Quote q -> [Quote q])
            if (List.forall (fun (elem) -> elem = args.[0]) args) then
                Atom (Symbol "t")
            else
                List []
<commit_msg>arithmetic fix<commit_after>﻿module Naggum.Runtime

open System
open Types
open Context

let add = fun (sexp) ->
            let args = List.map (fun (x) ->
                                    match x with
                                    |Atom (Number n) -> n
                                    |List ([Atom (Number n)]) -> n
                                    |any ->
                                        eprintfn "Expected: Number\nGot: %A" any
                                        raise (new ArgumentException()))
                                (match sexp with
                                    | List xs -> xs
                                    | Atom a -> [Atom a]
                                    | Quote q -> 
                                        eprintfn "Expected: Number\nGot: Quote %A" q
                                        raise (new ArgumentException()))
            List.reduce (+) args |> Number |> Atom

let sub = fun (sexp) ->
            let args = List.map (fun (x) ->
                                    match x with
                                    |Atom (Number n) -> n
                                    |List ([Atom (Number n)]) -> n
                                    |any ->
                                        eprintfn "Expected: Number\nGot: %A" any
                                        raise (new ArgumentException()))
                                (match sexp with
                                    | List xs -> xs
                                    | Atom a -> [Atom a]
                                    | Quote q -> 
                                        eprintfn "Expected: Number\nGot: Quote %A" q
                                        raise (new ArgumentException()))
            List.reduce (-) args |> Number |> Atom

let mul = fun (sexp) ->
            let args = List.map (fun (x) ->
                                    match x with
                                    |Atom (Number n) -> n
                                    |List ([Atom (Number n)]) -> n
                                    |any ->
                                        eprintfn "Expected: Number\nGot: %A" any
                                        raise (new ArgumentException()))
                                (match sexp with
                                    | List xs -> xs
                                    | Atom a -> [Atom a]
                                    | Quote q -> 
                                        eprintfn "Expected: Number\nGot: Quote %A" q
                                        raise (new ArgumentException()))
            List.reduce (*) args |> Number |> Atom

let div = fun (sexp) ->
            let args = List.map (fun (x) ->
                                    match x with
                                    |Atom (Number n) -> n
                                    |List ([Atom (Number n)]) -> n
                                    |any ->
                                        eprintfn "Expected: Number\nGot: %A" any
                                        raise (new ArgumentException()))
                                (match sexp with
                                    | List xs -> xs
                                    | Atom a -> [Atom a]
                                    | Quote q -> 
                                        eprintfn "Expected: Number\nGot: Quote %A" q
                                        raise (new ArgumentException()))
            List.reduce (/) args |> Number |> Atom

let equal = fun (sexp) ->
            let args =
                (match sexp with
                 | List xs -> xs
                 | Atom a -> [Atom a]
                 | Quote q -> [Quote q])
            if (List.forall (fun (elem) -> elem = args.[0]) args) then
                Atom (Symbol "t")
            else
                List []

{'fraction_non_alphanumeric': 0.08345632631155239, 'fraction_numerical': 0.0002683483161143164, 'mean_word_length': 0.6016330038676407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 100, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '862839', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1486, 'n_words': 503}