Board Logo
« Search Results »

Welcome Guest. Please Login or Register.
Mar 27th, 2017, 5:27pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ


Search Results

Total results: 10


 1   JB Programming Discussions / Re: One handed clock  on: Today at 4:04pm
Started by bplus | Post by tenochtitlanuk ( John F)
User Image

At the parallel/antiparalllel positions the seconds hand will be at some odd position.
Note I have not optimised the routine to get fractional-second answers!

 
  Reply Quote Notify of replies

 2   JB Programming Discussions / Re: One handed clock  on: Today at 3:57pm
Started by bplus | Post by tsh73
120 degrees version (well, actually 20 minutes since it checks up to minute (circumference / 60))
(with expanded bubble sort)
Code:
maxS=12*60*60
'print maxS
't0=time$("ms")

open "clock" for graphics as #gr
#gr "fill white; down"
#gr "trapclose quit"

'timer 0, [tick]

for s = 0 to maxS-1
    'sec = s mod 60
    'minute = int(s/60) mod 60
    hour = int(s/60/60)
    hour5 = 5*s/60/60
    minute = (s/60) mod 60
    sec = s mod 60
    'print hour6, minute, sec
    'now, check they are 20 minutes (circumference/3) apart
    m(1)=int(hour5+.5)
    m(2)=int(minute+.5)
    m(3)=sec
    'sort
    if m(1)>m(2) then tmp=m(2):m(2)=m(1):m(1)=tmp
    if m(2)>m(3) then tmp=m(3):m(3)=m(2):m(2)=tmp
    if m(1)>m(2) then tmp=m(2):m(2)=m(1):m(1)=tmp
    'check
'    if hour = 1 then
'        print int(hour5/5);":"; int(minute);":"; sec, m(3) - m(2),m(2) - m(1)
'    end if
    if m(3) - m(2) = 20 _
        and m(2) - m(1) = 20 then
        print int(hour5/5);":"; int(minute);":"; sec, "equal"
        #gr "color red"
        gosub [draw]
        call pause 500
        #gr "color black"
    end if
    'wait
'[tick]
    gosub [draw]
next
'print time$("ms")-t0
wait

sub quit hndl$
    close #gr
    end
end sub

[draw]
    #gr "cls"
    #gr "home; north; turn ";sec*6;";go 120"
    #gr "home; north; turn ";int((minute)*6+.5);";go 100"
    #gr "home; north; turn ";int((hour5)*6+.5);";go 70"
return

sub pause mil
    t0=time$("ms")
    while time$("ms") < t0+mil
        scan
    wend
end sub
 

 
  Reply Quote Notify of replies

 3   JB Programming Discussions / Re: One handed clock  on: Today at 3:37pm
Started by bplus | Post by tsh73
Ha! Pure math.
A bit dry to my taste ;)

in my program, "parallel" referred to all three arms pointing to same direction. "antiparallel" used for all other arrangements then all three arms forming stright line.

Here's version that checks only hour and minute

(btw for "pause" allowing to quit without error trapclose should be a sub, like here)
Code:
maxS=12*60*60
'print maxS
't0=time$("ms")

open "clock" for graphics as #gr
#gr "fill white; down"
#gr "trapclose quit"

'timer 0, [tick]

for s = 0 to maxS-1
    'sec = s mod 60
    'minute = int(s/60) mod 60
    'hour = int(s/60/60)
    hour5 = 5*s/60/60
    minute = (s/60) mod 60
    sec = s mod 60
    'print hour6, minute, sec

    if int(minute*60+.5)=int(hour5*60+.5) then
        print int(hour5/5);":"; int(minute);":"; sec, "parallel"
        #gr "color red"
        gosub [draw]
        call pause 300
        #gr "color black"
    else
        if  ((int(minute*60+.5)-int(hour5*60+.5)+60*60) mod (60*30)) = 0 then
            print int(hour5/5);":"; int(minute);":"; sec, "anti parallel"
            #gr "color blue"
            gosub [draw]
            call pause 300
            #gr "color black"
        end if
    end if
    'wait
'[tick]
    gosub [draw]
next
'print time$("ms")-t0
wait

sub quit hndl$
    close #gr
    end
end sub

[draw]
    #gr "cls"
    #gr "home; north; turn ";sec*6;";go 120"
    #gr "home; north; turn ";int((minute)*6+.5);";go 100"
    #gr "home; north; turn ";int((hour5)*6+.5);";go 70"
return

sub pause mil
    t0=time$("ms")
    while time$("ms") < t0+mil
        scan
    wend
end sub
 


 
  Reply Quote Notify of replies

 4   Novice / Re: Has JB something like the foreach of C#?  on: Today at 11:35am
Started by HansDunkelberg | Post by zzz000abc
on Today at 10:48am, Rod wrote:
so perhaps we need a better idea about what granularity of similarity you seek.

It seems he would define/put some similarity/check rules.
for example (i) one of the word from first phrase is reversed in the second phrase but need not necessarily be at the same place.say last word in second phrase may be first word in first phrase but reversed.(ii)all the words formed by first and second phrases are formed by same set of letters/alphabets etc.
there is only two possibilities either the similarity test passes or fails.
if it passes he assigns some nonzero value ,he calls it significance value.
if it fails he assigns a zero.
 
  Reply Quote Notify of replies

 5   Novice / Re: Has JB something like the foreach of C#?  on: Today at 10:48am
Started by HansDunkelberg | Post by Rod
So it would appear we are looking for "similarities" in text. So there is some granularity. No point in looking for letter combinations since THE and HE ETC will throw up hundreds of false matches. Is it phrases we are more interested in? WHEREFOR ART THOU ROMEO or TO BE SURE, TO BE SURE or UP THOSE APPLES AND PEARS.

Letter by letter hardly seeks similarities in language, so perhaps we need a better idea about what granularity of similarity you seek.

As tsh73 suggests characters can be linked by their distance apart on the keyboard or their frequency of use in any language, so we need to better understand the ultimate goal.
 
  Reply Quote Notify of replies

 6   Novice / Re: Has JB something like the foreach of C#?  on: Today at 09:37am
Started by HansDunkelberg | Post by tsh73
Code to calculate distance between leter on keyboard - on my keyboard that is.
Code:
'latin keyboard, all letters, selected same amount of latters
row$(1)="qwertyuiop"
row$(2)="asdfghjkl;"
row$(3)="\zxcvbnm,."

colLen=len(row$(1))

for i = 1 to 26
    print i,  chr$(asc("a")+i-1)
next

dim dist(26, 26)

for row1=1 to 3
    for col1=1 to colLen
        a$=mid$(row$(row1), col1, 1)
        if instr("abcdefghijklmnopqrstuvwxyz", a$)=0 then [skip]    'not a letter
        a=asc(a$)-asc("a")+1  'letter number
        for row2=1 to 3
            for col2=1 to colLen
                b$=mid$(row$(row2), col2, 1)
                if instr("abcdefghijklmnopqrstuvwxyz", b$)=0 then [skip2]
                b=asc(b$)-asc("a")+1    'another letter number
                'now distance
                d = sqr((row1-row2)^2+(col1-col2)^2)
                dist(a,b)=d
                [skip2]
            next
        next
        [skip]
    next
next

'now let's print that distance, 26x26 table
'header
print "    ";
for i = 1 to 26
    print chr$(asc("A")+i-1);"  ";
next
print
'table
for i = 1 to 26
    print chr$(asc("A")+i-1);" ";
    for j = 1 to 26
        print using("###", dist(i,j));
    next
    print
next

 

Distance table:
Code:
    A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
A   0  5  3  2  2  3  4  5  7  6  7  8  7  6  8  9  1  3  1  4  6  4  1  2  5  1
B   5  0  2  3  4  2  1  1  3  1  2  3  2  1  4  4  5  3  4  2  2  1  4  3  2  4
C   3  2  0  1  2  1  1  2  4  3  4  5  4  3  5  6  4  2  2  2  4  1  3  1  3  2
D   2  3  1  0  1  1  2  3  5  4  5  6  5  4  6  7  2  1  1  2  4  2  1  1  3  1
E   2  4  2  1  0  1  2  3  5  4  5  6  5  4  6  7  2  1  1  2  4  3  1  2  3  2
F   3  2  1  1  1  0  1  2  4  3  4  5  4  3  5  6  3  1  2  1  3  1  2  1  2  2
G   4  1  1  2  2  1  0  1  3  2  3  4  3  2  4  5  4  1  3  1  2  1  3  2  1  3
H   5  1  2  3  3  2  1  0  2  1  2  3  2  1  3  4  5  2  4  1  1  1  4  3  1  4
I   7  3  4  5  5  4  3  2  0  1  1  1  2  2  1  2  7  4  6  3  1  4  6  5  2  6
J   6  1  3  4  4  3  2  1  1  0  1  2  1  1  2  3  6  3  5  2  1  2  5  4  1  5
K   7  2  4  5  5  4  3  2  1  1  0  1  1  1  1  2  7  4  6  3  1  3  6  5  2  6
L   8  3  5  6  6  5  4  3  1  2  1  0  1  2  1  1  8  5  7  4  2  4  7  6  3  7
M   7  2  4  5  5  4  3  2  2  1  1  1  0  1  2  3  7  4  6  4  2  3  6  5  3  6
N   6  1  3  4  4  3  2  1  2  1  1  2  1  0  3  4  6  4  5  3  2  2  5  4  2  5
O   8  4  5  6  6  5  4  3  1  2  1  1  2  3  0  1  8  5  7  4  2  4  7  6  3  7
P   9  4  6  7  7  6  5  4  2  3  2  1  3  4  1  0  9  6  8  5  3  5  8  7  4  8
Q   1  5  4  2  2  3  4  5  7  6  7  8  7  6  8  9  0  3  1  4  6  4  1  3  5  2
R   3  3  2  1  1  1  1  2  4  3  4  5  4  4  5  6  3  0  2  1  3  2  2  2  2  3
S   1  4  2  1  1  2  3  4  6  5  6  7  6  5  7  8  1  2  0  3  5  3  1  1  4  1
T   4  2  2  2  2  1  1  1  3  2  3  4  4  3  4  5  4  1  3  0  2  2  3  3  1  4
U   6  2  4  4  4  3  2  1  1  1  1  2  2  2  2  3  6  3  5  2  0  3  5  4  1  5
V   4  1  1  2  3  1  1  1  4  2  3  4  3  2  4  5  4  2  3  2  3  0  4  2  2  3
W   1  4  3  1  1  2  3  4  6  5  6  7  6  5  7  8  1  2  1  3  5  4  0  2  4  2
X   2  3  1  1  2  1  2  3  5  4  5  6  5  4  6  7  3  2  1  3  4  2  2  0  4  1
Y   5  2  3  3  3  2  1  1  2  1  2  3  3  2  3  4  5  2  4  1  1  2  4  4  0  4
Z   1  4  2  1  2  2  3  4  6  5  6  7  6  5  7  8  2  3  1  4  5  3  2  1  4  0
 

 
  Reply Quote Notify of replies

 7   Novice / Re: Has JB something like the foreach of C#?  on: Today at 09:12am
Started by HansDunkelberg | Post by tsh73
Bring more examples.
What goes in, what are results.

As for
Quote:
I want users to be able to define what shall be considered similar, themselves

It is hardly reasonable to expect user to fill some tables *before* program could be even tried.
I think you will need to provide some starting point for that - some sample.
So you as well could start with it.

Quote:
256 different units would certainly not appear as satisfactory, from such a point of view.

As I've said it could be unused. You probably can start with 26 uppercase letters.

Quote:
it appears to me as essential that also set-scenes of languages like the English "th", "sh", "tch", etc. can be treated as units.

How abour starting simple, with single letters?
 
  Reply Quote Notify of replies

 8   Novice / Re: Has JB something like the foreach of C#?  on: Today at 08:56am
Started by HansDunkelberg | Post by zzz000abc
Hi, HansDunkelberg there are certain things still not clear.
what I understud by your posts is:
* for input you use 2 phrases ,each phrase is formed (min1
to max8)quintets.
* a quintet is a word formed by (min1 to max5) letters.
* for this you use 3 special variables of the form qij,sij,cij and new variables
are formed qijsij,qijcij.
upto here ok but here onwords there is ambiguity in your posts.
what is the meaning of q13s45? according to your post at one place, q13 means to consider 1 st quintent of first sample and 3rd quintent of 2nd sample.
q13s45 means 4th element of 1st quintent of first sample and 5th element of 3rd quintent of second sample.
at other place you said q12s11,q12s22,q12s33,q12s44 means to consider
1/2,2/3,3/4,4/5 respectively contradictng your own idea.seems you are confused with your algorithm or you not able to explain it properly.
next thing is how do you define cij you did not explain any where?

 
  Reply Quote Notify of replies

 9   Novice / Re: Has JB something like the foreach of C#?  on: Today at 03:36am
Started by HansDunkelberg | Post by HansDunkelberg
I am such a primitive beginner that I hardly understand anything, in the code you (tsh73) suggest. A problem I, in spite of this, assume would probably arise is that I want users to be able to define what shall be considered similar, themselves. Moreover, I also want to enable users to input whole groups of letters, instead of single ones, in such a way that these groups will be treated in the same way like single symbols. 256 different units would certainly not appear as satisfactory, from such a point of view.

To treat the input, like you suggest it, via the lines

Code:
a$="ASDF YUIP"
b$="SDFG HJKL" 


would currently not work, in my concoction. I have 16 separate input fields (8 for sample 1 and 8 for sample 2). This approach I would not much like to give up, because it appears to me as essential that also set-scenes of languages like the English "th", "sh", "tch", etc. can be treated as units.
 
  Reply Quote Notify of replies

 10   Novice / Re: Has JB something like the foreach of C#?  on: Today at 02:52am
Started by HansDunkelberg | Post by tsh73
I really have no idea what are you doing but for me "significance of letter pairs" calls for 256x256 array, for each letter pair (nothing bad if some of it would be unused).
So have a look on this.
Code:
'source string
a$="ASDF YUIP"
b$="SDFG HJKL"
'pairs significances
dim ps(255,255) '0..255 is possible letter code
'A-S, S-D, D-F, and F-G
'10, 14, 8, and 9
ps(asc("A"), asc("S"))=10
ps(asc("S"), asc("D"))=14
ps(asc("D"), asc("F"))=8
ps(asc("F"), asc("G"))=9

startA=1    'start of group A
startB=1    'start of group B
gosub [multyplySignificance]
print "Res = ";res

startA=1    'start of group A
startB=2    'start of group B
gosub [multyplySignificance]
print "Res = ";res

end

[multyplySignificance]
res=1   'for multiply, it starts with 1
for i = 1 to 4  'group len
    ca$=mid$(a$,i+startA-1,1)    'i-th letter from group A
    cb$=mid$(b$,i+startB-1,1)    'i-th letter from group B
    print ca$;"-";cb$;" => ";ps(asc(ca$), asc(cb$))
    res=res*ps(asc(ca$), asc(cb$))
next
return
 

 
  Reply Quote Notify of replies


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Just BASIC wiki
Wikispaces

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls