Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 27 Jul 2017, 11:06
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Compiling
fig 2.9 compiler / help docs / examples
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [19 Posts]   Goto page: 1, 2 Next
Author Message
learnhow2code

Joined: 12 Jun 2016
Posts: 1015

PostPosted: Wed 22 Jun 2016, 03:27    Post subject:  fig 2.9 compiler / help docs / examples  

here is fig 2.9, the "easiest" to learn educational language since logo and basic (perhaps.)

http://murga-linux.com/puppy/viewtopic.php?mode=attach&id=99110

# fig29 will be in /usr/local/bin
# docs in /root/fig2.9
# examples in /root/fig2.9/examples

package is 2-300k, fig is about 60k, written in python 2.

fig has about 100 commands, is text-based, does some graphics.

.pet file installed okay with tahr, which includes python (so there are no other requirements.)

if you install pygame, you get graphics. if you dont install pygame, you still get graphics Smile kind of.

feel free to ask questions here, or in the programming forum.

Last edited by learnhow2code on Sat 02 Jul 2016, 12:14; edited 1 time in total
Back to top
View user's profile Send private message 
learnhow2code

Joined: 12 Jun 2016
Posts: 1015

PostPosted: Sun 26 Jun 2016, 01:21    Post subject: Re: fig 2.9 compiler / help docs / examples  

learnhow2code wrote:
here is fig 2.9, the "easiest" to learn educational language since logo and basic (perhaps.)

https://dox.me/f/eb8SJ if someone could mirror this or help get it posted here, its only 292k.


couldnt find a better hosting option, so i managed to do the pet without the large gif image. you can still get the gif file (recommended for new users) here: http://imgur.com/oZ0zc1M

.pet file now attached to this post.

Quote:
feel free to ask questions here, or in the programming forum.
fig-2.9.pet
Description 
pet

 Download 
Filename  fig-2.9.pet 
Filesize  12.82 KB 
Downloaded  160 Time(s) 
Back to top
View user's profile Send private message 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 1473
Location: nyc

PostPosted: Tue 28 Jun 2016, 19:14    Post subject:  

mirror for fig-2.9.pet and related files.
Back to top
View user's profile Send private message 
learnhow2code

Joined: 12 Jun 2016
Posts: 1015

PostPosted: Fri 01 Jul 2016, 03:00    Post subject:  

Puppus Dogfellow wrote:
mirror for fig-2.9.pet and related files.


thank you very much for that.

im fond of the .pet format, as its relatively simple and easy to make.

for those who are just wild about .deb packages, a guy i know just made this into a .deb file: http://distro.ibiblio.org/refracta/files/extra_packages/fig31_1.0.deb

tahr can load it with:

Code:
cd /root
wget http://distro.ibiblio.org/refracta/files/extra_packages/fig31_1.0.deb
cd /
undeb /root/fig31_1.0.deb


although i recommend commenting out the the "cd /" line, as removing it will let you inspect the contents before moving them to /usr/bin and /usr/share/doc/fig ; i also recommend pasting the code into a text editor before running it, as its generally a good idea.

now, why would you want a .deb over a .pet? you probably wouldnt, unless you wanted to use the same file across your puppy and debian-based distros. most people would prefer the .pet package.
logo.16.gz
Description 
gz

 Download 
Filename  logo.16.gz 
Filesize  8.28 KB 
Downloaded  92 Time(s) 

_________________
users | devs
fig os 1.3 md5

Last edited by learnhow2code on Fri 15 Jul 2016, 00:23; edited 1 time in total
Back to top
View user's profile Send private message 
ASD

Joined: 22 Mar 2016
Posts: 99

PostPosted: Fri 01 Jul 2016, 04:03    Post subject:  

Hi,

Thank you. I am interested, but confused. The deb version seems to be more recent than the pet version, but more importantly it seems to be more than three times the size of the pet version.

Also, I have tahr-6.0.5 and I would normally expect to install any deb package by just left clicking on it (as I would to install any pet).

I have a few prime number (very short) progs which I wrote in GWBasic some 30 years ago. I have no idea about variations in different versions of basic and I may like to seek further advice how to update those progs (in another free version of basic) to handle larger prime numbers (and perhaps be compiled to run faster).
.
Back to top
View user's profile Send private message 
learnhow2code

Joined: 12 Jun 2016
Posts: 1015

PostPosted: Fri 01 Jul 2016, 04:32    Post subject:  

ASD wrote:
I am interested, but confused. The deb version seems to be more recent than the pet version, but more importantly it seems to be more than three times the size of the pet version.


happy to help. the .pet version was made very recently (a little over a week ago) by me, and the .deb version was made by someone i know, a day or two ago. theyre very close.

the .deb version includes fig29 (2.9) the python 2 version, same as the .pet package. it also includes fig31 (3.1) the python 3 version, which is potentially useful to debian users but i think puppy only has python 2 (fwiw i prefer 2.)

also i removed a large gif file (link here) to make the .pet fit in the 250k limit on this forum.

also there are a few other files (none are required) included in the .deb version.

Quote:
Also, I have tahr-6.0.5 and I would normally expect to install any deb package by just left clicking on it (as I would to install any pet).


we have the same version of tahr, but i am less familiar with it. i found undeb and i like it, you should be able to install this .deb the way you normally do. (let me know.)

Quote:
I have a few prime number (very short) progs which I wrote in GWBasic some 30 years ago. I have no idea about variations in different versions of basic and I may like to seek further advice how to update those progs (in another free version of basic) to handle larger prime numbers (and perhaps be compiled to run faster).
.


i would be happy to have a look at small programs and find out whats possible. feel free to paste those here, or in another thread where you think is best.

for a few programs, no change of license is necessary-- will work with you. beyond 3 or 4 programs, id feel more comfortable helping you translate code if its under some gpl-compatible or mit-compatible license. even a simple one. let me know how strict or permissive a license youd like your code to be used/reused under, im pretty flexible.

also if you dont want help translating and just want to know "how do i do [task] in fig?" thats fine too. any code i reply to (specifically) you with will be in the public domain to use however you like.

(none of that is a requirement to use the software here-- fig is very permissively in the public domain so you can use it however you like.)

questions welcome.
Back to top
View user's profile Send private message 
ASD

Joined: 22 Mar 2016
Posts: 99

PostPosted: Fri 01 Jul 2016, 05:29    Post subject:  

Hi again,

Thank you for your helpful response to my post.

As you now stress recommendation of your pet and gif for Pup use (rather than the alternative deb) I will just send you a short PM about my deb test.

I am looking forward to any advice you may have on my GWBasic progs and I will post details later today.
Back to top
View user's profile Send private message 
ASD

Joined: 22 Mar 2016
Posts: 99

PostPosted: Fri 01 Jul 2016, 14:43    Post subject:  

Four GWBasic programs to:

1 Find the actual No of Primes < x (x <= 39602) and, optionally, list them
plus the estimated No and the sum of the natural logs of primes <= x
uses the prime number theorem (the “-1“ adjustment suits small numbers)

2 Find the actual No of Pairs of Twin Primes < x (x <= 39602) and list them
plus the estimated No using the conjecture of Hardy and Littlewood

3 Find the actual No of Primes in intervals of x up to x^2 + 2x (x <= 180)
re the x^2 (prime in every row ) conjecture of Sierpinski with “+ 2x” tweak

4 Find the least No of Primes in any row of length x from a chosen No of rows
plus the position(s) of blank row(s), if any; and the total No of Primes

Notes:

All four programs use the Sieve of Eratosthanes (the screen shots of the four GWBasic progs and the actual progs will also be numbered 1 to 4 in later posts).

GWBasic had severe size restrictions (for prime number progs) so my four sieve programs were designed to ignore all even numbers (except the prime number 2)

There are, and were some 30 years ago when I wrote the above programs, many brilliant-beyond-belief free and freely available prime number applications, but I was intrigued by the output I hoped for and tried, from scratch, to write to above programs. My memory is now shot to pieces, but I recall I read the GWBasic manual from end to end then I read it again, making a note of anything I thought I might need. What is written below will be well known to most Forum members; however, as learnhow2code is promoting simplicity and understanding it seems helpful that I try to follow that lead.
-------------------------------

Here, with the aid of the screen shot, is how the Sieve of Eratosthanes works:

The numbers might just as well be in one long consecutive line, but the display in the screen shot is both traditional and convenient as my GWBasic programs 3 and 4 use rows. Also, I hope to write a new program based upon Schinzel's array conjecture concerning primes in columns.

Prime numbers are numbers divisible only by themselves and the number 1.

For technical reasons the number 1 is itself not regarded as a prime number.

The Sieve of Eratosthanes does not use division or factorisation it just counts in intervals of the prime p from each and every every new prime p which is equal to or less than the square root of x, where x is the largest integer chosen to be sieved.

So. in the table (a square array of 7 columns and 7 rows of dimension x ( x = 7) imagine all 49 numbers started out being yellow, then as and when any nth number is hit, using the sieve, it is composite (not prime) and turns white. So:

Firstly, we turn 1 white, because, as noted above, it is technically not a prime

Then 2 is a prime (the only even prime) so we leave it yellow but turn every second number from then on white - so 4, 6, 8, 10, 12 .... and all even numbers

Then 3 is a prime so we leave it yellow and turn every third number white (effectively ignoring it if already white) - so 9, 15, 21, 27, 33 .... turn white,
but 6, 12, 18 .... are already white from the previous step

Then the next yellow number is 5, so we leave it yellow and turn every fifth number white. Of the numbers 10, 15, 20, 25, 30, 35, 40 and 45; all except
25, 35 are already white so we just turn 25 and 35 white.

Then 7 is the next yellow number, so we leave it yellow and turn every seventh
number white. Of the numbers 14, 21, 28, 35, 42 and 49; all except 49 are already white so we turn 49 white.

Now, as no number greater than the square root of 49 (which is 7) can have two prime factors greater than 7 we have finished and the 15 prime numbers equal to or less than 49 that are left in yellow are:
2, 3, 5, 7. 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, and 47 as shown in the table.
eg.png
 Description   
 Filesize   2.99 KB
 Viewed   425 Time(s)

eg.png

Back to top
View user's profile Send private message 
ASD

Joined: 22 Mar 2016
Posts: 99

PostPosted: Fri 01 Jul 2016, 15:00    Post subject:  

Here are the screen shot listings of the GWBasic programs, numbered as in my post above. The terms "x" (used there) and "n" (used in the listings) are interchangeable.
1.png
 Description   
 Filesize   19.31 KB
 Viewed   403 Time(s)

1.png

2.png
 Description   
 Filesize   19.34 KB
 Viewed   408 Time(s)

2.png

3.png
 Description   
 Filesize   17.89 KB
 Viewed   412 Time(s)

3.png

4.png
 Description   
 Filesize   19.36 KB
 Viewed   417 Time(s)

4.png

Back to top
View user's profile Send private message 
ASD

Joined: 22 Mar 2016
Posts: 99

PostPosted: Fri 01 Jul 2016, 15:09    Post subject:  

Here are the four programs. In each case edit out the last three (dot g z) characters after download.

DOSBox (in tahr-6.0.5 PPM and many Pups) will run GWBasic and GWBasic v 3.23 can be found on the net.

I used v 3.20 to write the programs and if anybody is interested I can post it here with simple instructions for use.
1.BAS.gz
Description 
gz

 Download 
Filename  1.BAS.gz 
Filesize  712 Bytes 
Downloaded  60 Time(s) 
2.BAS.gz
Description 
gz

 Download 
Filename  2.BAS.gz 
Filesize  738 Bytes 
Downloaded  48 Time(s) 
3.BAS.gz
Description 
gz

 Download 
Filename  3.BAS.gz 
Filesize  610 Bytes 
Downloaded  64 Time(s) 
4.BAS.gz
Description 
gz

 Download 
Filename  4.BAS.gz 
Filesize  714 Bytes 
Downloaded  52 Time(s) 
Back to top
View user's profile Send private message 
learnhow2code

Joined: 12 Jun 2016
Posts: 1015

PostPosted: Fri 01 Jul 2016, 15:21    Post subject:  

ASD wrote:
DOSBox (in tahr-6.0.5 PPM and many Pups) will run GWBasic and GWBasic v 3.23 can be found on the net.

I used v 3.20 to write the programs and if anybody is interested I can post it here with simple instructions for use.


hey, would you mind doing those with the save"filename",a option?

i know its possible to find a copy of basic somewhere and run it in dosbox but theres no reason not to upload these in plaintext.

_________________
users | devs
fig os 1.3 md5
Back to top
View user's profile Send private message 
Pete


Joined: 02 Mar 2014
Posts: 675

PostPosted: Fri 01 Jul 2016, 16:03    Post subject:  

@ASD

Oh wow, GWBASIC, I had completely forgotten about it, fond memories.
Come to think of it now, also used QB4.5, but that was many, many moons ago. Smile
Back to top
View user's profile Send private message 
learnhow2code

Joined: 12 Jun 2016
Posts: 1015

PostPosted: Fri 01 Jul 2016, 16:22    Post subject:  

here is 1.BAS

(complete program is slightly further down the thread)

if you want to do a lot of heavy math, i recommend using the inline python feature. it has order of operations, etc.

this will give you an idea of what fig is like, but fig was not designed for people that love math. for them, the inline python feature-- once youre used to it-- is probably the only way to make fig suit your needs. you can do a sieve in pure fig (well, you need log(z) and log(2) for this) and you will get past your 39602 limit, but there you have it.

Last edited by learnhow2code on Sat 02 Jul 2016, 01:51; edited 1 time in total
Back to top
View user's profile Send private message 
ASD

Joined: 22 Mar 2016
Posts: 99

PostPosted: Fri 01 Jul 2016, 18:55    Post subject:  

Hi,

Thanks for your response. I have been enjoying some Friday night drinks in good company, so I'll respond later tomorrow by editing this post.

Meanwhile, it would be ideal if the last few Lines of "1.BAS" could be completed in "fig" either with or without using the natural logs of the primes together with detailed advice how to run the completed fig version of "1.BAS".
Back to top
View user's profile Send private message 
learnhow2code

Joined: 12 Jun 2016
Posts: 1015

PostPosted: Fri 01 Jul 2016, 20:59    Post subject:  

ASD wrote:
it would be ideal if the last few Lines of "1.BAS" could be completed in "fig" either with or without using the natural logs of the primes together with detailed advice how to run the completed fig version of "1.BAS".


you compile with fig29 1.fig and then run ./1.fig.py to run the compiled output.

example output with value of 1000000 is included in the code:

Code:
FUNCTION LOG Z
#we dont have a log function in fig, sorry; but we can steal one from python:
LF
PYTHON
    from math import log
    lf = log(z)
    FIG
NOW RETURN LF
FIG

FUNCTION BEEP
    # depends largely on settings
    X    7    CHR    PRINTS
    FIG

X    CLS    "INPUT 1 to display all primes on screen; to omit them ENTER"    PRINT
F    COLORTEXT 0    HIGHLIGHT 7    LINEINPUT    COLORTEXT 7

TRY
NOW F INT
EXCEPT
NOW 0
RESUME
F NOW

X    "input n for number of primes < n [n MUST BE EVEN]"    PRINT
N    LINEINPUT    INT
X    "WAIT FOR BEEP"                                        PRINT
S    N    TOPWR .5    INT
B    3
DIM  N    DIVBY 2     INT    PLUS 1
A_   ""   ARR    TIMES DIM

WHILE
INDEX    B    PLUS 1    DIVBY 2    INT    PLUS 1    ARRGET A_ INDEX
IFEQUAL INDEX "a"
    PASS
ELSE
    START B   PLUS  1    DIVBY 2    PLUS B
    STOP N    DIVBY 2
    STEP B
    FOR A START STOP STEP
        AINDEX A    PLUS 1
        A_    ARRSET AINDEX "a"    #### A_(A) = "a"
        NEXT
    IFMORE B S
        BREAK
        FIG
    FIG

INC B    PLUS 2    SWAP INC B
WEND
C 1   
L 2    LOG    2    CLS
IFEQUAL F 1
    NOW "2\t" PRINTS
    FIG

START 2
STOP N DIVBY 2
FOR A START STOP 1
    AINDEX A PLUS 1
    CK ARRGET A_ AINDEX
    IFEQUAL CK "a"
        PASS
    ELSE
        NOW C    PLUS 1    SWAP NOW C    #### C=C+1
        Z 2      TIMES A   MINUS 1
        NOW Z    LOG Z     PLUS L    SWAP NOW L    #### L=L+LOG(Z)
        IFEQUAL F 1
            NOW Z PRINTS "\t" PRINTS
            FIG         
        FIG
    NEXT

NOW ""    PRINT    PRINT
LZ Z      LOG Z    MINUS 1
T  Z      DIVBY LZ    INT    PRINT

NOW "" PRINT
NOW "The number of primes not exceeding "          PRINTS   
NOW N    PRINTS    " is "                          PRINTS
NOW C    PRINTS    " v. expected "                 PRINTS
NOW T    PRINTS    " and the largest prime is "    PRINTS
NOW Z    PRINT

NOW "The sum of the natural logs of the primes up to " PRINTS
NOW Z    PRINTS    " is "    PRINTS
NOW L    PRINTS    " and the percentage is "    PRINTS
NOW L    DIVBY Z   TIMES 100    PRINT    BEEP    END


PYTHON
    """
        ==== OUTPUT: ====

$ fig29 1.fig > /dev/null
$ ./1.fig.py

INPUT 1 to display all primes on screen; to omit them ENTER

input n for number of primes < n [n MUST BE EVEN]
1000000
WAIT FOR BEEP

78029

The number of primes not exceeding 1000000 is 78498 v. expected 78029 and the largest prime is 999983
The sum of the natural logs of the primes up to 999983 is 998484.175026 and the percentage is 99.8501149545
$
    """
FIG
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [19 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Compiling
Jump to:  

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
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0819s ][ Queries: 12 (0.0090s) ][ GZIP on ]