Eeems wrote:
could you set it up so that if the second argument in sum(14) is blank that it will default to pushing Ans?
Extremely easily, and I shall indeed do so. Smile
ah ok good Smile it will make for some good small optimizations in case you already have the number in answer Razz
Eeems wrote:
ah ok good Smile it will make for some good small optimizations in case you already have the number in answer Razz
Precisely. I've started in on implementing this, and the code on my end is most certainly not going to be pretty. Sad
_player1537 wrote:
another idea ... sum(14,2 return the data type that was last pushed.

Though at first I didn't like this idea, I now see it as pretty useful, if only because you can't compare numbers and strings. For instance, I put the string "EOS" at the bottom of the stack, and I want to be able to check if you're there, so I want to be able to do swap(15):If Ans="EOS"... but if you happen to also be pushing numbers, this check won't work. What I propose is a function that checks the type of Ans.

Code:
sum(17) - Check type of Ans
Returns:
1 - Number
1.1 - Real
1.2 - Complex
2 - List
2.1 - Real
2.2 - Complex
3 - Matrix
3.1 - Real
3.2 - Complex
5 - String
5.1 - String that can be evaluated by expr(

Example:
sum(15
sum(14
sum(17
If iPart(Ans=5: Then
sum(15->Str4
If Str4="EOS
Then
Disp "EOS Reached
Return
End
Str4
sum(14
End
Does anyone else think this would be worthwhile?
Have you checked out det(3)?

http://dcs.cemetech.net/index.php?title=Third-Party_BASIC_Libraries
KermMartian wrote:

Quote:
08:24 < merthsoft> KermM: Is there any documentation for det(3?
08:25 <+KermM> Merth, yes
08:26 <+KermM> | | Real = 0 | | List = 1
| | Matrix = 2 | | Equation = 3
| | String = 4 | | Complex = 12
| | Cpx List = 13

That is basically what I need. Some more features would be nice, but not necessary (except for the checking if expr( can handle it, unless that's what it means to be an equation.).
merthsoft wrote:
KermMartian wrote:

Quote:
08:24 < merthsoft> KermM: Is there any documentation for det(3?
08:25 <+KermM> Merth, yes
08:26 <+KermM> | | Real = 0 | | List = 1
| | Matrix = 2 | | Equation = 3
| | String = 4 | | Complex = 12
| | Cpx List = 13

That is basically what I need. Some more features would be nice, but not necessary (except for the checking if expr( can handle it, unless that's what it means to be an equation.).
No, that just checks if it's of type equation. I'm not sure how I would even check if it's a valid expr() string. Razz
KermMartian wrote:
merthsoft wrote:
KermMartian wrote:

Quote:
08:24 < merthsoft> KermM: Is there any documentation for det(3?
08:25 <+KermM> Merth, yes
08:26 <+KermM> | | Real = 0 | | List = 1
| | Matrix = 2 | | Equation = 3
| | String = 4 | | Complex = 12
| | Cpx List = 13

That is basically what I need. Some more features would be nice, but not necessary (except for the checking if expr( can handle it, unless that's what it means to be an equation.).
No, that just checks if it's of type equation. I'm not sure how I would even check if it's a valid expr() string. Razz


What's it mean to be of type equation? Like, "Y=5X" or something? Isn't "6" an equation?
No, 6 is a real, 6i is a complex, "6" and "6i" are strings, and Y1="6" is an equation. It's a very fine distinction between strings and equations. Razz
would a swap() command be feasible?

ie,


Code:
:100
:sum(14 //I think that is the push command
:22
:sum(14
:11
:swap()
:Disp Ans


Would display 22. It would swap the current Answer with the most recently pushed Answer on the stack.
_player1537 wrote:
would a swap() command be feasible?

ie,


Code:
:100
:sum(14 //I think that is the push command
:22
:sum(14
:11
:swap()
:Disp Ans


Would display 22. It would swap the current Answer with the most recently pushed Answer on the stack.

It's pretty simple if you use an external variable.

Code:
100
sum(14
22
sum(14
sum(15->A
11
sum(14
A
Disp Ans
why not pop the latest entry, store it into a variable, pop the next entry, store it in another variable, and then push them back on in reverse order.

actually, I think there is a routine using xor that would require only one external variable.

besides, if we could access any point in the stack, it wouldn't be a stack, but a list.

Just my two cents.
Merth, would that fulfill your need for a swap function? I was just thinking about it, and I'll have to do some awkward memory manipulation (which worries me given the numbers below). If it's worth it I have no problem, but if Merth's swap example is good enough, I won't do it.


Code:
Page 0 is 15675 bytes long (709 bytes to spare)
Page 1 is 15904 bytes long (480 bytes to spare)
Page 2 is 15924 bytes long (460 bytes to spare)
KermMartian wrote:
Merth, would that fulfill your need for a swap function? I was just thinking about it, and I'll have to do some awkward memory manipulation (which worries me given the numbers below). If it's worth it I have no problem, but if Merth's swap example is good enough, I won't do it.


Code:
Page 0 is 15675 bytes long (709 bytes to spare)
Page 1 is 15904 bytes long (480 bytes to spare)
Page 2 is 15924 bytes long (460 bytes to spare)
Eh, what I wanted was arbitrary location swapping, but it's nothing that can't be done with BASIC, and that would be more space, I assume. It'd be a lot faster in ASM, and I wouldn't have to worry about typing as I swap things around (it's sad, you can't store a string as a Number). Having more any-typed vars would be pretty sweet. Or another stack Wink.

Wait, I like that idea. Can we have another stack?
graphmastur wrote:
why not pop the latest entry, store it into a variable, pop the next entry, store it in another variable, and then push them back on in reverse order.

actually, I think there is a routine using xor that would require only one external variable.

besides, if we could access any point in the stack, it wouldn't be a stack, but a list.

Just my two cents.
Indeed, that would do the trick. I'm inclined to omit a swap function for now, because it seems like every programmer wants a different functionality based on what he or she is trying to make.

Merth, you mean multiple stacks? Ans0, Ans1, Ans2...? Oh geez, that sounds painful, but actually wouldn't be that bad. Do you (and everyone else) actually want me to do that?

Edit: Of course, the stack number would be specified as a second arg to sum14/15/16, and by default 14 and 15 would use 0, while 16 would delete them all.

Graphmastur, Tanner, Merth: Shall I make DCS automatically clean up [all the] stack[s] after a program returns to the DCS desktop? OR no?
I don't know about multiple stacks. they might come in handy, but I can't think of anything off-hand.

What about tree support? That should be fun to code. Wink

yes to the cleanup. It would tidy things up.
KermMartian wrote:
Merth, you mean multiple stacks? Ans0, Ans1, Ans2...? Oh geez, that sounds painful, but actually wouldn't be that bad. Do you (and everyone else) actually want me to do that?

Edit: Of course, the stack number would be specified as a second arg to sum14/15/16, and by default 14 and 15 would use 0, while 16 would delete them all.

Graphmastur, Tanner, Merth: Shall I make DCS automatically clean up [all the] stack[s] after a program returns to the DCS desktop? OR no?

16 can't delete them all! What if you just want to clear one?! I'd rather it not clean up the stack, but it's actually probably a good idea. If there's really anything I need to keep, I can use the Celtic stuff to store it long-term.
Are we talking as many stacks as we want? That would be sweet. I want it.
umm... multiple stacks... can't see what I'd use 'em for... idk

auto clean up, yes Very Happy

Edit: sum(16 deletes all, sum(16,# deletes stack #

Edit: Edit: actually, could someone explain that earlier code of Merth's for use with a list? My mind is a little fried today I think.
_player1537 wrote:
sum(16 deletes all, sum(16,# deletes stack #
That's cool. I'll take that.
merthsoft wrote:
_player1537 wrote:
sum(16 deletes all, sum(16,# deletes stack #
That's cool. I'll take that.
Yeah, that's what I was saying in my post. Apparently no one listens to me. Cool
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
» View previous topic :: View next topic  
Page 7 of 8
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement