Author |
Message |
|
Harrierfalcon The Raptor of Calcs
Super Elite (Last Title)
Joined: 25 Oct 2006 Posts: 2535
|
Posted: 30 Jan 2007 08:47:36 pm Post subject: |
|
|
Definitely. Time to get to work! |
|
Back to top |
|
|
calc84maniac
Elite
Joined: 22 Jan 2007 Posts: 770
|
Posted: 16 Feb 2007 09:07:27 am Post subject: |
|
|
If you're checking to see if a variable is equal to one of two values of the same parity (a.k.a. both odd or both even), you can use this:
For example, instead of
Code: If K=21 or K=105
use
Code: If 42=abs(K-63
It saves 2 bytes in this case, and is also faster according to my tests. :biggrin: |
|
Back to top |
|
|
georgexu
Newbie
Joined: 09 Feb 2007 Posts: 34
|
Posted: 16 Feb 2007 07:22:54 pm Post subject: |
|
|
instead of using
Code: A-(K=25)->A
A+(K=340->A
You can use
Code: A-(K=25)+(K=34)-A
This saves a little space
Last edited by Guest on 16 Feb 2007 07:24:52 pm; edited 1 time in total |
|
Back to top |
|
|
Harrierfalcon The Raptor of Calcs
Super Elite (Last Title)
Joined: 25 Oct 2006 Posts: 2535
|
Posted: 16 Feb 2007 08:28:34 pm Post subject: |
|
|
And it's faster.
Please be careful guys, many of these 'tricks' are already documented.
Occasionally, you'd want to [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]{1,2,3,4,5,6,7,8,9->L1. However, the smaller and 1337'er way to do it is [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]seq(Z,Z,1,9->L1.
The best use of Basic is when you use advanced commands/math like [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]seq(. However, [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]seq( has so many different applications it's not funny. |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 17 Feb 2007 04:42:48 pm Post subject: |
|
|
Upcoming may be a way to make seq() nearly obsolete forever. Be warned. |
|
Back to top |
|
|
Super Speler Super Awesome Dude
Calc Guru
Joined: 28 Nov 2005 Posts: 1391
|
Posted: 17 Feb 2007 04:56:53 pm Post subject: |
|
|
Hmm? Can't wait to see this.
EDIT: Hmm... Weregooses post disapeared?
Last edited by Guest on 17 Feb 2007 05:16:22 pm; edited 1 time in total |
|
Back to top |
|
|
Weregoose Authentic INTJ
Super Elite (Last Title)
Joined: 25 Nov 2004 Posts: 3976
|
Posted: 17 Feb 2007 05:19:18 pm Post subject: |
|
|
Weregoose's post was incorrect.
Last edited by Guest on 17 Feb 2007 05:19:28 pm; edited 1 time in total |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 17 Feb 2007 05:23:36 pm Post subject: |
|
|
Ok, here goes:
The basic idea is, [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]binomcdf(X,0 generates a list of X+1 1's. Rather quickly.
We don't much care for the number 1 repeated over and over again, so we'll want to add them up: [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]cumSum(binomcdf(X,0 is a smaller (by about one byte) and faster (by about a factor of five!) way of doing [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]seq(I,I,1,X. Incidentally, if you want to start at 0, you can do [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]cumSum(not(binompdf(X,0 (faster, although not smaller).
On to the basic applications: if you want to calculate something along the lines of [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]seq(f(I),I,1,X, you can do [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]f(cumSum(binomcdf(X,0 instead. This will be, as far as I can tell, always faster. It will be at least one byte smaller for prefix operations (when I goes at the end, such as in [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]sin(I), but larger for postfix operations (when I goes at the beginning, such as in [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]I!), due to ending parentheses.
Sometimes things don't go as well as you'd like them to: you'd like to start at something other than 0 or 1, or you want to have a step other than 1. Also, sometimes the expression inside [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]seq() will use a variable other than I.
We can take care of this too. A linear (mx+b) transformation will take card of the starting value and the step size (unfortunately, this makes this process slightly larger than the equivalent [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]seq() - but still faster). For the second problem, when we want to evaluate something like [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]seq(X+sin(X),X,1,100, it can be replaced with the following:
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]cumSum(binomcdf(99,0
Ans+sin(Ans
The catch: some operations can't take lists as arguments, only integers: for example, [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]seq(L1(I),I,1,10 has no equivalent using [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]binomcdf(). Also, you can only use this method to create lists of length 256 or less (a weird limitation).
Last edited by Guest on 17 Feb 2007 07:27:23 pm; edited 1 time in total |
|
Back to top |
|
|
Super Speler Super Awesome Dude
Calc Guru
Joined: 28 Nov 2005 Posts: 1391
|
Posted: 17 Feb 2007 05:54:41 pm Post subject: |
|
|
That's a great find. |
|
Back to top |
|
|
Weregoose Authentic INTJ
Super Elite (Last Title)
Joined: 25 Nov 2004 Posts: 3976
|
Posted: 17 Feb 2007 06:11:47 pm Post subject: |
|
|
I just got that feeling again, that there's still so much left to realize in this language.
Yay, this is impressive!
Last edited by Guest on 17 Feb 2007 06:12:12 pm; edited 1 time in total |
|
Back to top |
|
|
c_plus_plus My Face Hertz
Active Member
Joined: 30 Jan 2006 Posts: 575
|
Posted: 17 Feb 2007 07:15:41 pm Post subject: |
|
|
DarkerLine wrote: Incidentally, if you want to start at 0, you can do [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]cumSum(not(binompdf(X,0 (faster, although not smaller).
[post="97478"]<{POST_SNAPBACK}>[/post]
I haven't tried it but this doesn't seam like it will work. Am i missing something?
1. binompdf(X,0 gives a list of 1's
2. not(binompdf(X,0 would give a list of 0's
3. therefore, doing a cumSum would STILL be a list of 0's |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 17 Feb 2007 07:24:30 pm Post subject: |
|
|
binompdf(X,0 - not binomcdf(X,0 - gives {1,0,...,0}, that is, all the elements but the first are 0.
Also, I forgot to mention that you actually get X+1 elements from putting in X - fixed now.
binompdf(X,0
{1,0,0,...0}
binompdf(X,1
{0,0,...0,1}
binomcdf(X,0
{1,1,1,...,1}
binomcdf(X,1
{0,0,...,0,1}
Last edited by Guest on 17 Feb 2007 07:29:53 pm; edited 1 time in total |
|
Back to top |
|
|
Weregoose Authentic INTJ
Super Elite (Last Title)
Joined: 25 Nov 2004 Posts: 3976
|
Posted: 21 May 2007 05:31:24 am Post subject: |
|
|
This:
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]0→Xmin:1→ΔX
0→Ymin:1→ΔY
Over and done with.
You can save four bytes with one of the following instead:
[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]ZStandard
84→Xmin
52→Ymin
ZInteger
ZDecimal
90→Xmin
58→Ymin
ZInteger
ZTrig
88→Xmin
58→Ymin
ZInteger
Last edited by Guest on 15 Jun 2007 02:45:36 am; edited 1 time in total |
|
Back to top |
|
|
Harrierfalcon The Raptor of Calcs
Super Elite (Last Title)
Joined: 25 Oct 2006 Posts: 2535
|
Posted: 21 May 2007 06:57:09 am Post subject: |
|
|
Weregoose's optimizing skills strike again! Maybe I should look at what those graph settings do for a change... |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 21 May 2007 03:38:19 pm Post subject: |
|
|
I usually stick to [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]ZStandard:ZInteger which produces a different but also friendly window (from -47 to 47 for X, and -31 to 31 for Y). It's also guaranteed to make the graph screen as "dirty". |
|
Back to top |
|
|
TheStorm
Calc Guru
Joined: 17 Apr 2007 Posts: 1233
|
Posted: 21 May 2007 05:30:20 pm Post subject: |
|
|
Theses are all a big help keep up the good work!
For a 62*94 screen use
Code: :Zstandard
:104stoXmax
:72stoYmax
:Zinteger.
and for -62*94
Code: :Zstandard
:104stoXmax
:-72stoYmin
:Zinteger.
and the setupeditor [listname,listname...] command will unarchive multiple lists without giveing you an error if they don't exist or are unarchived, it will only create them.
then you can archive the lists at the end or you program and they will be removed from the list editor.
Last edited by Guest on 01 Jun 2007 10:52:00 pm; edited 1 time in total |
|
Back to top |
|
|
TheStorm
Calc Guru
Joined: 17 Apr 2007 Posts: 1233
|
Posted: 01 Jun 2007 10:45:26 pm Post subject: |
|
|
the fastest way to convert a string to a list is Code: seq(Instring("ABCD...",sub(str1,A,1)),A,1,length(str1)-> L1
where str1 is the string you want to convert and L1 is the resulting list. |
|
Back to top |
|
|
Harrierfalcon The Raptor of Calcs
Super Elite (Last Title)
Joined: 25 Oct 2006 Posts: 2535
|
Posted: 01 Jun 2007 10:48:13 pm Post subject: |
|
|
Congrats! You learned how to use seq(. This is more of a practical application than a trick, but it works nonetheless. |
|
Back to top |
|
|
TheStorm
Calc Guru
Joined: 17 Apr 2007 Posts: 1233
|
Posted: 01 Jun 2007 10:51:24 pm Post subject: |
|
|
Yeah I used a varent on that code to make saving highscores on lightnin game twice as fast.
more with seq(
to separate a list into two or more list you can use Code: seq(L1(A),A,1,10->L2
Where L1 is the starting list 1 is the starting point and 10 is the end and L2 is the resulting list.
Last edited by Guest on 01 Jun 2007 11:09:32 pm; edited 1 time in total |
|
Back to top |
|
|
Super Speler Super Awesome Dude
Calc Guru
Joined: 28 Nov 2005 Posts: 1391
|
Posted: 02 Jun 2007 09:51:12 am Post subject: |
|
|
Or in that case:
:L1->L2
:10->dim(L2
Which saves a few bytes. |
|
Back to top |
|
|
|