Author Topic: oh One-Handed Interpreter  (Read 13716 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #30 on: March 20, 2021, 08:20:18 pm »
I found 110 Terms of the Fiboacci Sequence the 111th missed by 1

Code: [Select]
' Test oh ar STx famous number to invert.txt 2021-03-16 need line 9 number in clipboard for line 2 to work.
' Update this test with the new inverse[PosInteger,NumberOfDecimalPlaces]

' copy paste STx number 23-9's, 1-8, 24-9's
STxNumber = 999999999999999999999998999999999999999999999999
. STxNumber to find inverse that equals first 100 plus terms of Fibonacci Series:
. STxNumber
.
. And drum roll.... the inverse is:
Fibonacci = inverse[STxNumber,4000]
. Fibonacci
.
. What do ya say we determine just exactly how many terms we have?
. ZZZ... press any to count terms.
zzz
f1 = 1
f2 = 1
startSearch = 1
termN = 2
[
fN = add[f1,f2]
searchFor = bnd[0,fN,0]
find = in3[startSearch,Fibonacci,searchFor]
if find
termN = a[termN,1]
. Term Number ;termN; = ;searchFor; found at ;find
f1 = f2
f2 = fN
startSearch = a[find,s[len[searchFor],1]]
el
. searchFor; not found, at least not found enclosed by 0's.
jmp 1
fi
]
. Here is the next 25 places after last find
. mid3[Fibonacci,startSearch,25]
. This concludes our search for the number of Fibonacci Terms in the inverse of Stx Number.

 
110 Terms Found.PNG

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #31 on: March 20, 2021, 10:00:46 pm »
Hey b+ there are 5 more try harder!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #32 on: March 20, 2021, 10:11:19 pm »
Throw out the 0's enclosure:
Code: QB64: [Select]
  1. ' Test oh ar STx famous number to invert.txt 2021-03-16 need line 9 number in clipboard for line 2 to work.
  2. ' Update this test with the new inverse[PosInteger,NumberOfDecimalPlaces]
  3.  
  4. ' copy paste STx number 23-9's, 1-8, 24-9's
  5. STxNumber = 999999999999999999999998999999999999999999999999
  6. . STxNumber to find inverse that equals first 100 plus terms of Fibonacci Series:
  7. . STxNumber
  8. .
  9. . And drum roll.... the inverse is:
  10. Fibonacci = inverse[STxNumber,4000]
  11. . Fibonacci
  12. .
  13. . What do ya say we determine just exactly how many terms we have?
  14. . ZZZ... press any to count terms.
  15. zzz
  16. f1 = 1
  17. f2 = 1
  18. startSearch = 1
  19. termN = 2
  20. [
  21.         searchFor = add[f1,f2]
  22.         find = in3[startSearch,Fibonacci,searchFor]
  23.         if find
  24.                 termN = a[termN,1]
  25.                 . Term Number ;termN; = ;searchFor; found at ;find
  26.                 f1 = f2
  27.                 f2 = searchFor
  28.                 startSearch = a[find,len[searchFor]]
  29.         el
  30.                 . searchFor; not found.
  31.                 jmp 1
  32.         fi
  33. ]
  34.  
  35. . Here is the next 30 places after last find
  36. . mid3[Fibonacci,startSearch,30]
  37. . This concludes our search for the number of Fibonacci Terms in the inverse of Stx Number.
  38.  

 
115 Terms after 2nd try.PNG


I am hoping to finish off ToDo List for next zip package with new Inverse[] SFunction.
« Last Edit: March 21, 2021, 12:26:51 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #33 on: March 21, 2021, 01:13:16 pm »
Yikes! I see I am using a : for line labels, that is not consistent with oh's name, look for \ to replace : in next update.

Thank goodness there is a symbol left without having to shift.

There are ` (not single quote) and - and / also, one might be used for double parking?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #34 on: March 21, 2021, 01:20:53 pm »
Re: replacing Colons with \

Oh! This is perfect job for strReplace[] time to get that loaded into oh and then make an oh app to change all the old oh program files!

Hope this works!
« Last Edit: March 22, 2021, 01:58:56 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #35 on: March 21, 2021, 03:04:32 pm »
Re: replacing Colons with \

Oh heck will need a files[] SFunction before a strReplace[],

funny how necessity is the Mother of Invention.

Those should be fairly easy to add (famous last words) if I could only get mom and dog and errands settled.

Spring has sprung in my neck of the woods :)
« Last Edit: March 22, 2021, 01:59:33 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #36 on: March 22, 2021, 01:52:10 am »
I have gutted front end of oh menu and replaced it with a file reader/contents scroller. Now when you load a file, it's contents are displayed and you can scroll through it to see if you want to run it or edit it or maybe load another or start a new file.

oh now has a files[] SFunction you can get a list of Files in the current directory.

oh now has the replace[source$,replace$,new$] SFunction.

Well here is the change log for v2021-03-22:
Code: [Select]
*** 2021-03-22
3/20 added inverse[PosInteger,NumberOfDecimals] for custom division or control of decimals.
     This is = 1/PosNumber to a set amount of decimals.
3/21 added files[] - no argument SFunction that loads the files of current directory into an AString.
3/21 added replace[stringSource,stringToReplace,StringToRplaceWith] - 3 arguments SFunction.
3/21 fix? load[] renders [ brackets impotent by swapping them with { brackets
save Astring;FileName sort of needs to reverse that by replacing { back to [
This is messy, in future something else may be a better solution.
3/21 Line labels now end with \ instead of colon. This is to be consistent to oh rule, no shifts.
3/21 Added another preloaded variable nl (Next Line) for file line delimiter.
Vnames$(11) = "NL": Vvalues$(10) = Chr$(13) + Chr$(10)
3/21 Gutted out opening code and rewrote the code to display files on a scroller when have a
     filename and existing file. Now the menu runs across top line in yellow and red and can
click menu item or key press first letter for New, Edit, Load, Run, or Quit.
Much better if I do say so myself :) This completes my goals for this revision.

This has advanced well beyond the SB1 Interpreter!
« Last Edit: March 22, 2021, 01:53:26 am by bplus »

Offline Ed Davis

  • Newbie
  • Posts: 40
    • View Profile
Re: oh One-Handed Interpreter
« Reply #37 on: March 22, 2021, 07:25:57 am »
This has advanced well beyond the SB1 Interpreter!

Yes it has!  I continue to be amazed at what you have done.  Very, very impressive!

I really think you should consider writing up a nice blurb about it and listing it here: https://esolangs.org/wiki/Main_Page

In any case, good job!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #38 on: March 22, 2021, 10:47:28 am »
Yes it has!  I continue to be amazed at what you have done.  Very, very impressive!

I really think you should consider writing up a nice blurb about it and listing it here: https://esolangs.org/wiki/Main_Page

In any case, good job!

Thanks Ed, really appreciate your comments. Since breakthrough 3/7 I have my hands full trying to keep the help/cheat sheet up to date; there is so much more I want to do. The reader is begging for improvements and why not do some file maintenance like moving or killing or navigating? I am considering a Syntax line checker next for an IDE eventually and how about user defined commands and functions? That's on backburner and I think the syntax checker is good step towards that. That by the way is one of my favorite parts of QB45 and QB64 language, OK

I did do quick scan of link, seems there are more eso-languages than we have active members here ;-))
You can see in seconds people have fun with this stuff!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #39 on: March 23, 2021, 07:04:16 pm »
Update:
The problem with NL is fixed, Chr$(13) + Chr$(10) is now accessible "constant" as build in variable like xmax, ymax highest x, y pixel and  rmax, cmax highest row and column char cell you may loc (LOCATE).

Reader/Scroller now responds to PgUp, PgDn, Home, and End keypresses along with mouse-wheel scrolling.

The text in reader is now filtered replacing chars < 32 with * unless a tab which is replaced by 4 spaces. Now the len of lines are controlled so the screen wont overprint and we never loose sight of the top line menu in red and yellow while displaying the file lines (up to 127 chars in width with tabs converted to 4 spaces).

Starting on OK$ syntax checking of an oh program line. CmdList$ has 40 commands registered and FunList$ has 74 SFunctions registered. Now for the hard part...  ;-))

These changes will be included in next zip packaged to be announced below.

« Last Edit: March 25, 2021, 12:48:59 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #40 on: March 27, 2021, 01:44:23 am »
Update 2021-03-27 several fixes plus syntax checking started.

Here is change log for oh v2021-03-27:
Code: [Select]
*** 2021-03-27
3/23 Fix file display scroller to accept PgUp, PgDn, Home, End Keypresses.
Also run file lines through filter JIT to replace tabs with 4 spaces and other
chars < 32 with *. This enables the display of 39 lines on 39 lines without screen
scrolling and menu line lost.
3/23 NL fixed and working as expected in: Test oh replace and nl.txt file.
3/23 Adding SHARED Lists: CmdList$ and FunList$ for Function OK$ a line Syntax checker function
that will return nothing (OK) if the line is fine, or what it found wrong with proposed
program line. Inventory: 40 commands (fix 4 more), 74 SFunctions
3/26 Added 3 more procedures for Syntax checking and immediately learned I missed 4 commands in
     command list. The only line it caught after that was an title line without a formal comment.
I started editing Particle Fountain (it is hopelessly S L O W) and the syntax checker caught
a missing argument in an Or line when I mistakenly typed a } instead of a regular ] bracket.
Good, it catches at least something. So now lines start with comments, commands, variables
or line labels\ (\ ends a line label now).
3/27 Fixed - Mouse Action Shooter - the first bullet fired was always nothing?? and yet 10 points
     is deducted from the score as it should be. Show me the bullet! I just initialized all the
bullets properties instead of only the bLive AStrings (arrays).
3/27 Fixed. After editing a file, you have to change directory and change back to get the new
     file loaded with the changes. I now do that automatically in code after an Edit.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #41 on: March 27, 2021, 01:56:00 pm »
There is a flaw with bracket checking that I hope to fix today. It should not effect good code but warn against missing closing ]'s and should catch more bad code with missing or misplaced closing ]'s.
 

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #42 on: March 27, 2021, 06:20:31 pm »
OK the bracket ] locating is fixed as well as flagging unrecognized SFunctions ( String Functions that use []'s )

Not much to Change Log:
Code: [Select]
*** 2021-03-27A
3/27A Syntax checking had a little sloppy handling of closing ] assuming it was at end of line
     instead of checking if one was actually there to match opening [. I found 4
working programs that were missing a final bracket at the end. I also found a program
that used [] instead of parenthesis and it was flagged for unknown SFunction. So that part
of syntax checking is also fixed, you will be flagged for unrecognized functions.
So I went through all working programs and they now fly through syntax checking right into
a successful run.

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: oh One-Handed Interpreter
« Reply #43 on: May 26, 2021, 06:51:48 am »
my Fibonacci algorithm use string$ and checks addition to column visually

Code: [Select]
7                                 8
8                                13
9                                21
...
24                            28657
25                            46368
26                            75025
...
76                 2111485077978050
77                 3416454622906707
78                 5527939700884757
79                 8944394323791464
80            1.447233402467622D+16

https://www.qb64.org/forum/index.php?topic=3935.msg132756#msg132756

results write in file for addition more spaces
manually or automatically for viewing comfortable

Code: QB64: [Select]
  1. OPEN "fibo12345.txt" FOR OUTPUT AS #1
  2. ...
  3. PRINT #1, i,
« Last Edit: May 26, 2021, 07:53:38 pm by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: oh One-Handed Interpreter
« Reply #44 on: May 26, 2021, 02:40:58 pm »
I used oh Interpreter to ask question what is first term that is 100 digits long and to load that number in clipboard for using later. I also showed third through 10th terms just to see that it was counting correctly.

Code: QB64: [Select]
  1. ' Test oh Fibonacci test find first 100 digit Fibonacci Number
  2. f1 = 1
  3. f2 = 1
  4. count = 2
  5. [
  6.         fNew = add[f1,f2]
  7.         f1 = f2
  8.         f2 = fNew
  9.         count = a[count,1]
  10.         if lte[count,10]
  11.                 , count;fNew
  12.                 .
  13.         fi
  14.         if eq[len[fNew],100]
  15.                 clipout fNew
  16.                 , count;fNew
  17.                 .
  18.                 exit
  19.         fi
  20. ]
  21.  
  22. ' clipboard has this:
  23. ' 1344719667586153181419716641724567886890850696275767987106294472017884974410332069524504824747437757
  24.  

confirmed it is 100 digits:
Code: QB64: [Select]
  1. s$ = "1344719667586153181419716641724567886890850696275767987106294472017884974410332069524504824747437757"
  2.  

This mod of Steve's code confirms the 476th Fibonacci term is first with 100 digits assuming first is 1 and 2nd is 1, Steve started a little earlier ;-))
Code: QB64: [Select]
  1. 'Fibonacci for 1000 numbers
  2.  
  3. 'If it seems odd that there's a thanks in the funtion to myself, that's because I shamelessly stole add$
  4. 'from bplus.  :P
  5.  
  6.  
  7. Screen _NewImage(1024, 300, 32)
  8. a$ = "1": b$ = "1" ' first 2 terms
  9. For i = 3 To 480
  10.     c$ = add$(a$, b$)
  11.     a$ = b$
  12.     b$ = c$
  13.     'Print c$
  14.     If i >= 475 Then Print i; Len(c$); c$
  15.  
  16.  
  17.  
  18. Function add$ (a$, b$) 'add 2 positive integers assume a and b are just numbers no spaces or - signs
  19.     'first thing is to set a and b numbers to same length and multiple of 18 so can take 18 digits at a time
  20.     Dim la As Integer, lb As Integer, m As Integer, g As Integer
  21.     Dim fa$, fb$, t$, new$, result$
  22.     la = Len(a$): lb = Len(b$)
  23.     If la > lb Then m = Int(la / 18) + 1 Else m = Int(lb / 18) + 1
  24.     fa$ = Right$(String$(m * 18, "0") + a$, m * 18)
  25.     fb$ = Right$(String$(m * 18, "0") + b$, m * 18)
  26.  
  27.     'now taking 18 digits at a time Thanks Steve McNeill
  28.     For g = 1 To m
  29.         sa = Val(Mid$(fa$, m * 18 - g * 18 + 1, 18))
  30.         sb = Val(Mid$(fb$, m * 18 - g * 18 + 1, 18))
  31.         t$ = Right$(String$(36, "0") + _Trim$(Str$(sa + sb + co)), 36)
  32.         co = Val(Mid$(t$, 1, 18))
  33.         new$ = Mid$(t$, 19)
  34.         result$ = new$ + result$
  35.     Next
  36.     If co Then result$ = Str$(co) + result$
  37.     Do Until Left$(result$, 1) <> "0" Or Len(result$) = 1
  38.         result$ = Mid$(result$, 2)
  39.     Loop
  40.     add$ = result$
  41.  
  42.  
  43.  
Oh Fibon 100.PNG
* Oh Fibon 100.PNG (Filesize: 6.22 KB, Dimensions: 955x215, Views: 171)
first 100 digits Fibon mod Steve code.PNG
* first 100 digits Fibon mod Steve code.PNG (Filesize: 15.38 KB, Dimensions: 1031x168, Views: 167)
« Last Edit: May 26, 2021, 02:50:55 pm by bplus »