lightweight webgl rendering tool
Scheme(R7RS) interpretor/compiler rust implementation
A simple less compiler for unix-like environment
online suduku game
parser generator
Mr. Stark, I miss you
a Q&A community of HUST
push eventDanielmelody/Ruschm
commit sha a224215c4254de20e1c86deb61abf05d443ba78f
feat(parser): parsing pattern language refactor(parser): parser::repeat as a lazy parser combinator fix(lexer): eating delimiter on percular identifiers refactor(parser): impl From T for Located<T>
push time in 9 hours
PR opened Danielmelody/Ruschm
refactor(parser): parser::repeat as a lazy parser combinator fix(lexer): eating delimiter on percular identifiers refactor(parser): impl From T for Located<T>
pr created time in 9 hours
push eventDanielmelody/Ruschm
commit sha 8d2387718797123d8026491b52e28a07aef5d9a9
feat(parser): parsing pattern language refactor(parser): parser::repeat as a lazy parser combinator fix(lexer): eating delimiter on percular identifiers refactor(parser): impl From T for Located<T>
push time in 9 hours
push eventDanielmelody/Ruschm
commit sha 20c2431ba9bcb675672aa2e29db693b7f25ebce1
feat(parser): parsing pattern language Also refactor parser::repeat as a lazy parser combinator Fix a bug of lexer that eating delimiter on percular identifiers
push time in 9 hours
push eventDanielmelody/Ruschm
commit sha b485fdec3a3a01045f74893f5b05ea8248dd284e
temp
push time in 18 hours
startedEmbarkStudios/rust-gpu
started time in 4 days
push eventDanielmelody/Ruschm
commit sha 7fbd5d94b4975d1f8d2b37f239b6e3a40e7aab20
refactor: remove internal logic out of mod.rs
push time in 11 days
push eventDanielmelody/Ruschm
commit sha 7fdc2c12ec90b7ab2b64ac78b7dd2d5c8f868d8e
feat(enviroment): add buildin-function not
commit sha 8b8cab543b8bca1403ea71c1385c5673858e5dc5
feat(enviroment): buildin function boolean=?
commit sha 8d21812cbb8d8ecb9e03032987d167dca5b475df
feat(enviroment): buildin function eq?
commit sha 621bcd30870f071d899f8c1b4cb7b970a52fa676
feat: add some pre-define scheme/base library functions
commit sha ab7b81786bcb79a8063190d240f3c337161904ce
fix: temporally close tail optimization test
push time in 11 days
push eventDanielmelody/Ruschm
commit sha 89b94490ca6591c13cbd14295513a772051d5f7c
fix: temporally close tail optimization test
push time in 11 days
startedwenhan-wu/OpenCourseCatalog
started time in 13 days
pull request commentDanielmelody/Ruschm
feat: add some pre-define scheme/base library functions
@CurryPseudo Seems adding some scheme function as library in env breaks tail call optimization, see above test. The assert_eq run into overflows when try to compare TailExpressionResult
I don't understand why, modifying environment should not cause that. I guess the tail call optimization wasn't implement well.
commit e58f3024f4d8343087e07be27ad65cf2306193f6 uncover this problem.
comment created time in 14 days
push eventDanielmelody/Ruschm
commit sha d45297d25fa75df55fd9e163d608910c8264599e
feat(enviroment): add buildin-function not
commit sha a1086ed77d2c4e5af9ee68a59bcf22fc3c55a687
feat(enviroment): buildin function boolean=?
commit sha a75818e774b3b81eb1a68f64765d45b6c9ce7459
feat(enviroment): buildin function eq?
commit sha e58f3024f4d8343087e07be27ad65cf2306193f6
feat: add some pre-define scheme/base library functions
push time in 14 days
push eventDanielmelody/Ruschm
commit sha 0aa9e0fef83bd1fec7445ae562cbb63d27fe8ae6
feat(enviroment): add buildin-function not
push time in 14 days
push eventDanielmelody/Ruschm
commit sha ff893e7ab1b189bbbf68830c6dfdfc4f5268f6ab
feat: value expect more
push time in 16 days
push eventDanielmelody/Ruschm
commit sha d36508dc35d97b69becf50bfeabc688486b77ade
refactor: export macro match_expect_type
push time in 16 days
startedsbcl/sbcl
started time in 20 days
push eventDanielmelody/Danielhu229.github.io
commit sha 77919313f86b7c353aba7e28662524b2233b8e0b
site update
push time in a month
push eventDanielmelody/Ruschm
commit sha cd8efe9ad83c4899a97343f6d2953a8e8ab8a0f9
feat: primitive type pridicates
commit sha d22578ce4b15a745a216248504712f8bc5fd6848
feat: eqv? predicates
commit sha 80ed6dcc31f17c74d7787fad9e49ae473ff8311d
refactor: move value definitions out of interpreter
push time in a month
startedKhronosGroup/SPIRV-LLVM-Translator
started time in a month
startednamin/inc
started time in a month
push eventDanielmelody/Ruschm
commit sha 46cf150bff3094b55af21bd45ca1f7e228f4c527
fix: vector literal should keep elelments unevaluated
push time in a month
PR merged Danielmelody/Ruschm
fix #48 (proc xxx) inside vector literal will be considered as a list
pr closed time in a month
issue closedDanielmelody/Ruschm
vector literal should include procedure call
src/interpreter/mod.rs minimal:
#(1 2 (vector 1))
thread 'main' panicked at 'internal error: entered unreachable code: expression should not be ProcedureCall(Located { data: Identifier("vector"), location: Some([1, 14]) }, [Located { data: Integer(1), location: Some([1, 16]) }])', src\interpreter\mod.rs:788:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\release\ruschm.exe` (exit code: 101)
closed time in a month
CurryPseudoissue commentDanielmelody/Ruschm
vector literal should include procedure call
And also, identifier should evaluate to value while creating literal vector, not as symbol This is incorrect, for example:
(vector 'a 'b 'c) will generate#(a b c)` (from r7rs)
comment created time in a month
PR opened Danielmelody/Ruschm
fix #48 (proc xxx) inside vector literal will be considered as a list
pr created time in a month
push eventDanielmelody/Ruschm
commit sha f844507741bf7c2d63ddedb4e944272393f72a68
feat: pairs and lists
commit sha 94f693c2004a206c7321677a0125724880ab4c13
refactor some buildin procedures, wrap Vector in Rc, new buildin procedures (#47) * Use Value::expect_xxx to get the expect type of value, simplify the buildin library code * Add unit test for add, sub, mul, div, greater and min * Refactor Value::Vector to avoid clone, intro mutability * New buildin procedure vector-set!, vector-length and make-vector
commit sha 59d1eba4369bfb8283de0675871cd975a5d776d6
fix: vector literal should keep elelments unevaluated
push time in a month
Pull request review commentDanielmelody/Ruschm
Refactor some buildin procedures, wrap Vector in Rc, new buildin procedures
fn vector_ref<R: RealNumberInternalTrait, E: IEnvironment<R>>( ) -> Result<Value<R, E>> { let mut iter = arguments.into_iter(); match iter.next() {- None => logic_error!("vector_ref requires exactly two argument"),+ None => logic_error!("vector-ref requires exactly two argument"),
Since it was checked before call native function. should we just write an unreachable!()?
comment created time in a month
push eventDanielmelody/Ruschm
commit sha f844507741bf7c2d63ddedb4e944272393f72a68
feat: pairs and lists
push time in a month
PR merged Danielmelody/Ruschm
This PR implements pairs and list operations, and also fix the quotation problem. Now a quoted list is seen as a list literal, which will eval to a scheme object (aka interpreter::Value). Other quoted expressions are also literals of it's corresponding types, distinguished by it's formals.
Pairs can be constructed via (cons a b) or '(a . b). Proper list can be constructed via '(a b) or '(a b . ())
Data, aka scheme objects. aka Value, can be treated as program, and consumed by upcoming feature eval
Some buildin procedures are not implement, except car cdr pair? and cons . Procedures like list? can be implement in scheme, we will soon append it.
pr closed time in a month
PR opened Danielmelody/Ruschm
This PR implements pairs and list operations, and also fix the quotation problem. Now a quoted list is seen as a list literal, which will eval to a scheme object (aka interpreter::Value). Other quoted expressions are also literals of it's corresponding types, distinguished by it's formals.
Pairs can be constructed via (cons a b) or '(a . b). Proper list can be constructed via '(a b) or '(a b . ())
Some buildin procedures are not implement, expect car cdr pair? and cons . Procedures like list? can be implement in scheme, we will soon append it.
pr created time in a month
push eventDanielmelody/Ruschm
commit sha 557f91b355d8c945a997eedad3a723e44850dbc1
feat: pairs and lists
push time in a month
push eventDanielmelody/Ruschm
commit sha f1c4526d38d32301163b10251e05f2787f93c361
temp
push time in a month
startedcisco/ChezScheme
started time in a month
push eventDanielmelody/Ruschm
commit sha 3931cd7177ce9f96def92b410eb8aded46c04243
temp
push time in a month
Pull request review commentDanielmelody/Ruschm
New buildin procedure vector-set!, refactor all buildin procedures.
pub fn base_library<'a, R: RealNumberInternalTrait, E: IEnvironment<R>>( ), function_mapping!("display", vec!["value".to_string()], None, display), function_mapping!("newline", vec![], None, newline),- function_mapping!("vector", vec![], None, vector),+ function_mapping!("vector", vec![], Some("x".to_string()), vector), function_mapping!( "vector-ref", vec!["vector".to_string(), "k".to_string()], None, vector_ref ),+ function_mapping!(+ "vector-set!",+ vec!["vector".to_string(), "k".to_string(), "obj".to_string()],
maybe should named as index and obj
comment created time in a month
pull request commentDanielmelody/Ruschm
Seems some impls are not considered right, closed.
comment created time in a month
pull request commentDanielmelody/Ruschm
I 'd like to add test later... as me can curry are both doing a big refactor, we want to reduce conflicts.
comment created time in a month
push eventDanielmelody/Ruschm
commit sha 7fa26936cf1d10b7b90d754125e792f572a8a2a8
Refactor: RefCell on definition other than on environment (#43) * refactor: :art: RefCell on definition other than on environment * feat: :sparkles: enviroment can get_mut * fix: :bug: return (&String, &Value) iterator, improve get_mut's test Co-authored-by: curryyzheng <[email protected]>
commit sha 4e879aed419bbe880c01e1b3a04bb772d3368100
feat: list and pais
push time in a month
Pull request review commentDanielmelody/Ruschm
Refactor: RefCell on definition other than on environment
use crate::interpreter::scheme; use crate::interpreter::Interpreter; use crate::interpreter::RealNumberInternalTrait; use crate::interpreter::Value;-use std::cell::RefCell;+use cell::{Ref, RefCell, RefMut, RefVal}; use std::collections::HashMap; use std::rc::Rc; +pub type DefinitionIter<'a, R, E> = Box<dyn 'a + Iterator<Item = (&'a str, &'a Value<R, E>)>>;+ pub trait IEnvironment<R: RealNumberInternalTrait>: std::fmt::Debug + Clone + PartialEq { fn new() -> Self where Self: Sized;- fn define(&mut self, name: String, value: Value<R, Self>)+ fn define(&self, name: String, value: Value<R, Self>)+ where+ Self: Sized;+ fn get(&self, name: &str) -> Option<Ref<Value<R, Self>>> where Self: Sized;- fn get(&self, name: &str) -> Option<Value<R, Self>>+ fn get_mut(&self, name: &str) -> Option<RefMut<Value<R, Self>>> where Self: Sized;- fn set(&mut self, name: &str, value: Value<R, Self>) -> Result<(), SchemeError>+ fn set(&self, name: &str, value: Value<R, Self>) -> Result<(), SchemeError> where Self: Sized;- fn new_child(parent: Rc<RefCell<Self>>) -> Self+ fn new_child(parent: Rc<Self>) -> Self where Self: Sized; - fn iter_local_definitions<'a>(- &'a self,- ) -> Box<dyn 'a + Iterator<Item = (&'a String, &'a Value<R, Self>)>>;+ fn iter_local_definitions<'a, 'b: 'a>(&'b self) -> RefVal<'a, DefinitionIter<'b, R, Self>>; } #[derive(Clone, Debug, PartialEq)] pub struct StandardEnv<R: RealNumberInternalTrait> {- parent: Option<Rc<RefCell<StandardEnv<R>>>>,- definitions: HashMap<String, Value<R, StandardEnv<R>>>,+ parent: Option<Rc<StandardEnv<R>>>,+ definitions: RefCell<HashMap<String, Value<R, StandardEnv<R>>>>, } impl<R: RealNumberInternalTrait> IEnvironment<R> for StandardEnv<R> {- // type DefinitionCollection = std::collections::hash_map::Iter<'a, String, Value<R, StandardEnv<R>>>;- fn new() -> Self { Self { parent: None,- definitions: scheme::base::base_library::<R, StandardEnv<R>>(),+ definitions: RefCell::new(scheme::base::base_library::<R, StandardEnv<R>>()), } }- fn new_child(parent: Rc<RefCell<StandardEnv<R>>>) -> Self {+ fn new_child(parent: Rc<StandardEnv<R>>) -> Self { Self { parent: Some(parent),- definitions: HashMap::new(),+ definitions: RefCell::new(HashMap::new()), } } - fn define(&mut self, name: String, value: Value<R, Self>) {- self.definitions.insert(name, value);+ fn define(&self, name: String, value: Value<R, Self>) {+ self.definitions.borrow_mut().insert(name, value); } - fn get(&self, name: &str) -> Option<Value<R, Self>> {- match self.definitions.get(name) {- None => match &self.parent {- None => return None,- Some(parent) => parent.borrow().get(name),- },- Some(value) => Some(value.clone()),+ fn get(&self, name: &str) -> Option<Ref<Value<R, Self>>> {+ if self.definitions.borrow().contains_key(name) {+ Some(Ref::map(self.definitions.borrow(), |definitions| {+ definitions.get(name).unwrap()+ }))+ } else {+ match &self.parent {+ Some(parent) => parent.get(name),+ None => None,+ }+ }+ }+ fn get_mut(&self, name: &str) -> Option<RefMut<Value<R, Self>>> {+ if self.definitions.borrow().contains_key(name) {+ Some(RefMut::map(self.definitions.borrow_mut(), |definitions| {+ definitions.get_mut(name).unwrap()+ }))+ } else {+ match &self.parent {+ Some(parent) => parent.get_mut(name),+ None => None,+ } } } - fn set(&mut self, name: &str, value: Value<R, Self>) -> Result<(), SchemeError> {- match self.definitions.get_mut(name) {+ fn set(&self, name: &str, value: Value<R, Self>) -> Result<(), SchemeError> {+ match self.definitions.borrow_mut().get_mut(name) { None => match &self.parent { None => logic_error!("unbound variable {}", name),- Some(parent) => parent.borrow_mut().set(name, value)?,+ Some(parent) => parent.set(name, value)?, }, Some(variable) => *variable = value, }; Ok(()) } - fn iter_local_definitions<'a>(- &'a self,- ) -> Box<dyn 'a + Iterator<Item = (&'a String, &'a Value<R, Self>)>> {- Box::new(self.definitions.iter())+ fn iter_local_definitions<'a, 'b: 'a>(&'b self) -> RefVal<'a, DefinitionIter<'b, R, Self>> {+ Ref::map_val(self.definitions.borrow(), |definitions| {+ let iter: DefinitionIter<'b, R, Self> =+ Box::new(definitions.iter().map(|(s, v)| (s.as_str(), v)));
Currently just return what (&key, &value) stores is enough. We will consider it later in name interning
comment created time in a month
Pull request review commentDanielmelody/Ruschm
Refactor: RefCell on definition other than on environment
use crate::interpreter::scheme; use crate::interpreter::Interpreter; use crate::interpreter::RealNumberInternalTrait; use crate::interpreter::Value;-use std::cell::RefCell;+use cell::{Ref, RefCell, RefMut, RefVal}; use std::collections::HashMap; use std::rc::Rc; +pub type DefinitionIter<'a, R, E> = Box<dyn 'a + Iterator<Item = (&'a str, &'a Value<R, E>)>>;+ pub trait IEnvironment<R: RealNumberInternalTrait>: std::fmt::Debug + Clone + PartialEq { fn new() -> Self where Self: Sized;- fn define(&mut self, name: String, value: Value<R, Self>)+ fn define(&self, name: String, value: Value<R, Self>)+ where+ Self: Sized;+ fn get(&self, name: &str) -> Option<Ref<Value<R, Self>>> where Self: Sized;- fn get(&self, name: &str) -> Option<Value<R, Self>>+ fn get_mut(&self, name: &str) -> Option<RefMut<Value<R, Self>>> where Self: Sized;- fn set(&mut self, name: &str, value: Value<R, Self>) -> Result<(), SchemeError>+ fn set(&self, name: &str, value: Value<R, Self>) -> Result<(), SchemeError> where Self: Sized;- fn new_child(parent: Rc<RefCell<Self>>) -> Self+ fn new_child(parent: Rc<Self>) -> Self where Self: Sized; - fn iter_local_definitions<'a>(- &'a self,- ) -> Box<dyn 'a + Iterator<Item = (&'a String, &'a Value<R, Self>)>>;+ fn iter_local_definitions<'a, 'b: 'a>(&'b self) -> RefVal<'a, DefinitionIter<'b, R, Self>>; } #[derive(Clone, Debug, PartialEq)] pub struct StandardEnv<R: RealNumberInternalTrait> {- parent: Option<Rc<RefCell<StandardEnv<R>>>>,- definitions: HashMap<String, Value<R, StandardEnv<R>>>,+ parent: Option<Rc<StandardEnv<R>>>,+ definitions: RefCell<HashMap<String, Value<R, StandardEnv<R>>>>, } impl<R: RealNumberInternalTrait> IEnvironment<R> for StandardEnv<R> {- // type DefinitionCollection = std::collections::hash_map::Iter<'a, String, Value<R, StandardEnv<R>>>;- fn new() -> Self { Self { parent: None,- definitions: scheme::base::base_library::<R, StandardEnv<R>>(),+ definitions: RefCell::new(scheme::base::base_library::<R, StandardEnv<R>>()), } }- fn new_child(parent: Rc<RefCell<StandardEnv<R>>>) -> Self {+ fn new_child(parent: Rc<StandardEnv<R>>) -> Self { Self { parent: Some(parent),- definitions: HashMap::new(),+ definitions: RefCell::new(HashMap::new()), } } - fn define(&mut self, name: String, value: Value<R, Self>) {- self.definitions.insert(name, value);+ fn define(&self, name: String, value: Value<R, Self>) {+ self.definitions.borrow_mut().insert(name, value); } - fn get(&self, name: &str) -> Option<Value<R, Self>> {- match self.definitions.get(name) {- None => match &self.parent {- None => return None,- Some(parent) => parent.borrow().get(name),- },- Some(value) => Some(value.clone()),+ fn get(&self, name: &str) -> Option<Ref<Value<R, Self>>> {+ if self.definitions.borrow().contains_key(name) {+ Some(Ref::map(self.definitions.borrow(), |definitions| {+ definitions.get(name).unwrap()+ }))+ } else {+ match &self.parent {+ Some(parent) => parent.get(name),+ None => None,+ }+ }+ }+ fn get_mut(&self, name: &str) -> Option<RefMut<Value<R, Self>>> {+ if self.definitions.borrow().contains_key(name) {+ Some(RefMut::map(self.definitions.borrow_mut(), |definitions| {+ definitions.get_mut(name).unwrap()+ }))+ } else {+ match &self.parent {+ Some(parent) => parent.get_mut(name),+ None => None,+ } } } - fn set(&mut self, name: &str, value: Value<R, Self>) -> Result<(), SchemeError> {- match self.definitions.get_mut(name) {+ fn set(&self, name: &str, value: Value<R, Self>) -> Result<(), SchemeError> {+ match self.definitions.borrow_mut().get_mut(name) { None => match &self.parent { None => logic_error!("unbound variable {}", name),- Some(parent) => parent.borrow_mut().set(name, value)?,+ Some(parent) => parent.set(name, value)?, }, Some(variable) => *variable = value, }; Ok(()) } - fn iter_local_definitions<'a>(- &'a self,- ) -> Box<dyn 'a + Iterator<Item = (&'a String, &'a Value<R, Self>)>> {- Box::new(self.definitions.iter())+ fn iter_local_definitions<'a, 'b: 'a>(&'b self) -> RefVal<'a, DefinitionIter<'b, R, Self>> {+ Ref::map_val(self.definitions.borrow(), |definitions| {+ let iter: DefinitionIter<'b, R, Self> =+ Box::new(definitions.iter().map(|(s, v)| (s.as_str(), v)));
as_str is not necessary
comment created time in a month
push eventDanielmelody/Ruschm
commit sha c6d4a162336436c9bc84d28fa76f25a4ada85578
initial commit
commit sha 79fc8f8f6dc7296aa56edf82d6dd82981650ce06
Add GPL License
commit sha 72ac42b621d9e0482f60a56df3fb02e8d1a2d3b0
Add Gitter badge
commit sha d3ca2a2d514767c6a367044045ad4934efaabbdd
chore(build): typo
commit sha 404e09e0d0b98adea2e57a13a683c2aec15dce77
chore: add .editorconfig Use EditorConfig to define and maintain consistent coding styles
commit sha 9b70ee76b81369d81ac2af43e2566ef1e809f648
chore(git): update .gitignore Ignore tag files.
commit sha 55aac33b42a474399ca7d5727fb87ad5e797283b
:construction_worker: ignore Cargo.lock
commit sha 5e14876369dd79a12ca180951f0bad9c75e4d2f3
:construction_worker: rename repo
commit sha 6b0a0555851265de5cc3faf74e96dded6d349ddb
fix cargo edition
commit sha 262dc06478dc4cde58d45e5ef31f90f9286f7468
test
commit sha a9cc9a36c0a18c021d5973797ce8d8a21e6091c0
re-track Cargo.lock
commit sha d795990b5ca3ae4239b20259e5ce95bbebc5b61d
Create default.yml
commit sha 20f455148ee2e1e29fb636ee02273fbe07eb207b
Update default.yml
commit sha 9cf647615df5e87e27bb3111b38b41e86bcc4d19
add build status badge to README
commit sha 356fd702a632090cc20968c0cff4591901e11baf
Create workflow.yml
commit sha 0163dce3899089b6b95b48cd3d184e7407625af7
feat(lexer): simple tokens
commit sha ff30832fdf581e58ac1cabc900cf01352e2d5501
feat(lexer): identifier
commit sha 2f1f7ef7174db6658bd19fd76f768cfa0d82595e
feat(lexer): character
commit sha 9a21a23e77b5c916947fe2762ec271dead165cdc
feat(lexer): string
commit sha e50c16354f6424c627c7feccbde9f96887e20fba
refactor(lexer): retarget to r7r5
push time in 2 months
PR closed Danielmelody/Ruschm
IEnvironment::get should return Ref<Value> to do further optimization (like not to clone but reference a procedure). But this involves iter_local_definition's api changing, I think it's not a big problem.
pr closed time in 2 months
push eventDanielmelody/Ruschm
commit sha 156529d5920d13718d04ad762b759e73807cccec
refactor: make ParameterFormals displayable
push time in 2 months
push eventDanielmelody/Ruschm
commit sha 80108714b290a7a9de75c9fe4a64c062627b7eb6
refactor: make ParameterFormals displayable
push time in 2 months
push eventDanielmelody/Ruschm
commit sha 8f7d8362de1102a01033be68512b0110558f317f
refactor: chaining result handling to make parser as a hierarchical iterator over char streams
commit sha e58d8f635f54e5dab85ac8072e0601a66808d696
refactor: make ParameterFormals displayable
push time in 2 months
push eventDanielmelody/Ruschm
commit sha 8f7d8362de1102a01033be68512b0110558f317f
refactor: chaining result handling to make parser as a hierarchical iterator over char streams
push time in 2 months
PR merged Danielmelody/Ruschm
…terator over char streams
pr closed time in 2 months
push eventDanielmelody/Ruschm
commit sha 1612bd9901d59b073bd15a796da4e83a9aab2fd0
refactor: make ParameterFormals displayable
push time in 2 months
startedleon-ai/leon
started time in 2 months
push eventDanielmelody/Ruschm
commit sha d6220b183d4cb4dfe7348543743c2005ba5b2d9f
feat: some buildin procedures (#36) new buildin procedures: * vector-ref * floor * ceiling * floor-quotient * floor-remainder * exact Co-authored-by: curryyzheng <[email protected]>
push time in 2 months
Pull request review commentDanielmelody/Ruschm
feat: buildin procedure for implement ordered dither
impl<R: RealNumberInternalTrait> std::ops::Div<Number<R>> for Number<R> { } } +impl<R: RealNumberInternalTrait> Number<R> {+ pub fn sqrt(self) -> Self {+ match self {+ Number::Integer(num) => Number::Real(R::from(num).unwrap().sqrt()),+ Number::Real(num) => Number::Real(num.sqrt()),+ Number::Rational(a, b) => {+ Number::Real(R::from(a).unwrap() / R::from(b).unwrap().sqrt())+ }+ }+ }+ pub fn floor(self) -> Self {+ match self {+ Number::Integer(num) => Number::Integer(num),+ Number::Real(num) => Number::Real(num.floor()),+ Number::Rational(a, b) => Number::Integer({+ let quot = a / b;+ if quot >= 0 || quot * b == a {+ quot+ } else {+ quot - 1+ }+ }),+ }+ }++ pub fn floor_quotient(self, rhs: Self) -> Result<Self> {+ Ok((self / rhs)?.floor())+ }++ pub fn floor_remainder(self, rhs: Self) -> Result<Self> {+ Ok(self - self.floor_quotient(rhs)? * rhs)+ }++ // Return an exact number that is numerically closest to the given number+ pub fn exact(self) -> Result<Self> {+ match self {+ Number::Real(num) => match num.round().to_i32() {+ Some(i) => Ok(Number::Integer(i)),+ None => logic_error!("cannot be converted to an exact number"),+ },+ exact => Ok(exact),+ }+ }+}+#[test]+fn number_floor() {+ assert_eq!(Number::<f32>::Integer(5).floor(), Number::Integer(5));+ assert_eq!(Number::<f32>::Rational(28, 3).floor(), Number::Integer(9));+ assert_eq!(Number::<f32>::Rational(-43, 7).floor(), Number::Integer(-7));+ assert_eq!(Number::<f32>::Rational(43, -7).floor(), Number::Integer(-7));
Currently, Number::Rational can be (i32, i32), but from lexical, the can only be (i32, u32), it will be fix tn future, so do not test with negative divider.
comment created time in 2 months
push eventDanielmelody/Ruschm
commit sha 4414337ce4282ec028155c841ce15fdd1fc72152
feat: :sparkles: user defined variadic function
push time in 2 months
push eventDanielmelody/Ruschm
commit sha ca54604844f346a8a43b11ec1dab386cadf340ca
feat: :sparkles: user defined variadic function
push time in 2 months
push eventDanielmelody/Danielmelody
commit sha 0d08f91f748e1707ced2ca5e9f15d128364bc4d5
Update README.md
push time in 2 months
push eventDanielmelody/Danielmelody
commit sha 298bcc977e99ba3be9aa6e5d218a3b6bdd7236ff
Add anti-996 LIcense
push time in 2 months
issue commentdfranx/SPIRV-VM
fnLocation passed into spvm_state_prepare is not valid.
Well, I 'm developing a SDL targeting SPIR-V, and I 'm interesting debugging and validating my compiler by this vm. I 've googled an found this is the only SPIR-V vm in the world. I 'd be very appreciate if you can make this project more serious, like, for example, well tested.
comment created time in 2 months
startedimmunant/c2rust
started time in 2 months
issue commentdfranx/SPIRV-VM
fnLocation passed into spvm_state_prepare is not valid.
BTW, any plans for unit tests?
I 'm interesting on using your project, but I 'm not sure it is still in an early stage or full featured.
comment created time in 2 months
Pull request review commentDanielmelody/Ruschm
fix(lexer): prevent rational number denominator being zero
fn atmosphere() -> Result<()> { #[test] fn comment() -> Result<()> { assert_eq!(- tokenize("abcd;+-12\t\n\r 12")?,+ tokenize("abcd;+-12\n 12;dew\r34")?,
Oh... this should be another commit
But this is because \t should not be a special character for comments, it does not break comments.
comment created time in 2 months