Author Topic: BASIC One-Liners  (Read 4502 times)

0 Members and 1 Guest are viewing this topic.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
BASIC One-Liners
« on: January 10, 2011, 09:59:15 pm »
Post your favorite useful (or useless) one-line snippets of TI-BASIC code here! :D
I'll start us off with a few of my favorites, list operations:
Code: ("Total Occurences") [Select]
"Returns how many times Ans is an element in L1
sum(Ans=L1
Code: ("Single-Occurrence index") [Select]
"Finds where Ans is in L1 provided it only occurs once
1+dim(L1)-sum(cumSum(L1=Ans
Code: ("Occurrence index") [Select]
"Finds the index of the Xth occurrence of Ans in L1 (indexed from 1)
1+dim(L1)-sum(X<=cumSum(L1=Ans
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

SirCmpwn

  • Guest
Re: BASIC One-Liners
« Reply #1 on: January 10, 2011, 10:00:55 pm »
Shortest (and hardest) game ever:
Code: [Select]
Disp "The Game"

Offline Masinini

  • LV2 Member (Next: 40)
  • **
  • Posts: 33
  • Rating: +0/-0
    • View Profile
Re: BASIC One-Liners
« Reply #2 on: January 10, 2011, 10:02:47 pm »
Lbl 99.

Story is, I used to use number lbl's only, and before I knew how to optimize and about sub routines, I had a program that used 99 lbl's.
Output(1,1,"By the pricking of my thumb"
Txt(1,1, "Something wicked this way comes."

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: BASIC One-Liners
« Reply #3 on: January 10, 2011, 10:03:08 pm »
Also, before someone does it, no ':'s except as part of a string ;D
Sir, that can be optimized to
Code: [Select]
Disp "The Game:P
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BASIC One-Liners
« Reply #4 on: January 10, 2011, 10:15:17 pm »
Also, before someone does it, no ':'s except as part of a string ;D
Aw... I was gonna post xLIB xLIB Revolution source code ;D

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: BASIC One-Liners
« Reply #5 on: January 10, 2011, 10:26:17 pm »
Code: [Select]
:prgmXXR

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BASIC One-Liners
« Reply #6 on: January 10, 2011, 10:32:43 pm »
Lol Runer112. Finally it seems XXR isn't one single line, though. I thought it did because it barely used any text and the menu texts were sprites.

On an off-topic note I remember these days O.O





That was after XXR made Engadget front page, though (along with plenty of other blogs including Japanese ones). Still, I think that was the only time where a program beat VTI, Mario and MirageOS at once O.O
« Last Edit: January 10, 2011, 10:37:21 pm by DJ Omnimaga »

Offline sjasogun1

  • LV3 Member (Next: 100)
  • ***
  • Posts: 88
  • Rating: +8/-1
    • View Profile
Re: BASIC One-Liners
« Reply #7 on: January 13, 2011, 04:14:37 am »
Not really a one-liner, but still pretty small game written on my fx-9860 GII (yes on the calc itself, using the program function, not very efficiënt but whatever):

Spoiler For Spoiler:
“PRESS ANY NUMBER AND THEN EXE TO BEGIN”
? --> A
CLRTEXT
RAN# --> A
LOCATE 1,2,A
IF A<0.9
THEN LOCATE 12,2,”<0.9”
LOCATE 1,3,”SUCCESS!”
LOCATE 1,4,”LEVEL 1 COMPLETE”
LOCATE 1,5,”PRESS ANY NUMBER AND”
LOCATE 1,6,”THEN EXE TO CONTINUE”
? --> A
CLRTEXT
RAN# --> B
LOCATE 1,2,B
IF B<0.75
THEN LOCATE 12,2,”<0.75”
LOCATE 1,3,”SUCCESS!”
LOCATE 1,4,”LEVEL 2 COMPLETE”
LOCATE 1,5,”PRESS ANY NUMBER AND”
LOCATE 1,6,”THEN EXE TO CONTINUE”
? --> A
CLRTEXT
RAN# --> C
LOCATE 1,2,C
IF C<0.45
THEN LOCATE 12,2,”<0.45”
LOCATE 1,3,”SUCCESS!”
LOCATE 1,4,”LEVEL 3 COMPLETE”
LOCATE 1,5,”PRESS ANY NUMBER AND”
LOCATE 1,6,”THEN EXE TO CONTINUE”
? --> A
CLRTEXT
RAN# --> D
LOCATE 1,2,D
IF D<0.2
THEN LOCATE 12,2,”<0.2”
LOCATE 1,3,”SUCCESS!”
LOCATE 1,4,”LEVEL 4 COMPLETE”
LOCATE 1,5,”PRESS ANY NUMBER AND”
LOCATE 1,6,“THEN EXE TO CONTINUE”
? --> A
CLRTEXT
RAN# --> E
LOCATE 1,2,E
IF E<0.05
THEN LOCATE 12,2,”<0.05”
LOCATE 1,3,”SUCCESS!”
LOCATE 1,4,”LEVEL 5 COMPLETE”
LOCATE 1,5,”YOU WON! CONGRATULATIONS!”
LOCATE 1,6,”PRESS ANY KEY TO FINISH”
ELSE LOCATE 12,2,”>0.05”
LOCATE 1,3,”FAIL…”
IFEND
ELSE LOCATE 12,2,”>0.2”
LOCATE 1,3,”FAIL…”
IFEND
ELSE LOCATE 12,2,”>0.45”
LOCATE 1,3,”FAIL…”
IFEND
ELSE LOCATE 12,2,”>0.75”
LOCATE 1,3,”FAIL…”
IFEND
ELSE LOCATE 12,2,”>0.9”
LOCATE 1,3,”FAIL…”
IFEND
Veni, vidi, cecidi
(I came, I saw, I fell down dead)
MSPAFORUMS: http://www.mspaforums.com/
HOMESTUCK: http://www.mspaintadventures.com/?s=6&p=001901