|
Post by tenochtitlanuk on Nov 28, 2021 14:19:42 GMT -5
My browser barfed at the double slash in the supplied URL...
|
|
|
Post by tenochtitlanuk on Nov 28, 2021 3:53:26 GMT -5
Downloaded fine and it is impressive. The GUI front-end makes it very easily useable. I'll be playing with it when I have time. johnf PS thanks for the mention! LB and this forum have always been great places to share, help and admire!
|
|
|
Post by tenochtitlanuk on Nov 26, 2021 8:40:06 GMT -5
Just to note I've added a page on this, which was prompted by tsh73's post on the JB forum.
Cheerful graphics for Thanksgiving, and the approach of Christmas.
|
|
|
Post by tenochtitlanuk on Nov 21, 2021 17:28:47 GMT -5
A more normal way would be to use a subroutine as below. You also need the 'end' to avoid 'falling into' the definition of the sub. It also helps if you post LB code within the 'code' tags..
nomainwin
CToInput$ ="-2" if val( CToInput$) < 1 then call Notify
end
sub Notify notice "NOTICE!" + chr$(13) + "All information must be filled in " + chr$(13) + "before calculations can begin!" BadInfo = 1 end sub
|
|
|
Post by tenochtitlanuk on Nov 14, 2021 12:44:28 GMT -5
It looks like an interesting reference, but rather beyond me. There's a lot there and well worth dipping into. The pseudo-code is quite easy to follow. Keep us in touch if you get anywhere... I've coded things like HILL-CLIMBING and SIMULATED-ANNEALING. I'd certainly have been helped by a reference work like this one... The vocabularly has become specialised. Luckily Wikipedia helped me! 'A percept is the input that an intelligent agent is perceiving at any given moment.
In artificial intelligence, an intelligent agent (IA) is anything which perceives its environment, takes actions autonomously in order to achieve goals, and may improve its performance with learning or may use knowledge.'
EDIT I particlularly liked the examples of Language Processing. Also note it is a work-in-progress with many chapter headings with no content. I'll certainly be browsing it further, however.
|
|
|
Post by tenochtitlanuk on Nov 13, 2021 11:08:46 GMT -5
I've done several animations, including graphic Xmas trees at my web site Xmas animation and stained glass windows whose colours change. Fun to be getting seasonal!
|
|
|
Post by tenochtitlanuk on Nov 9, 2021 17:21:45 GMT -5
Yup, it IS quite fast! What I found most interesting is LB's performance in terms of precision. If you specify 'print using( "##.#######################", h), you can see it is expressing wrongly the least significant figures, but internally representing them precisely. Hence by working backwards from the result you get back to EXACTLY 1!
The first twenty harmonic numbers are: 0.99999999999999991611392 by adding 0.99999999999999991611392 1.49999999999999987417088 by adding 0.49999999999999995805696 1.83333333333333289992192 by adding 0.33333333333333327740928 2.08333333333333296283648 by adding 0.24999999999999997902848 2.28333333333333287895040 by adding 0.20000000000000000000000 2.44999999999999947571200 by adding 0.16666666666666663870464 2.59285714285714212913152 by adding 0.14285714285714284216320 2.71785714285714232836096 by adding 0.12499999999999998951424 2.82896825396825350471680 by adding 0.11111111111111109246976 2.92896825396825346277376 by adding 0.10000000000000000000000 3.01987734487734442524672 by adding 0.09090909090909089955840 3.10321067821067789139968 by adding 0.08333333333333331935232 3.18013375513375467896832 by adding 0.07692307692307692388352 3.25156232656232650899456 by adding 0.07142857142857142108160 3.31822899322899314769920 by adding 0.06666666666666665967616 3.38072899322899324731392 by adding 0.06249999999999999475712 3.43955252264075765219328 by adding 0.05882352941176469848064 3.49510807819631307259904 by adding 0.05555555555555554623488 3.54773965714368178946048 by adding 0.05263157894736841277440 3.59773965714368160071680 by adding 0.05000000000000000000000
3.547739657143682 by subtracting 0.05000000000000000000000 3.495108078196313 by subtracting 0.05263157894736841277440 3.439552522640758 by subtracting 0.05555555555555554623488 3.380728993228994 by subtracting 0.05882352941176469848064 3.318228993228994 by subtracting 0.06249999999999999475712 3.251562326562327 by subtracting 0.06666666666666665967616 3.180133755133755 by subtracting 0.07142857142857142108160 3.103210678210678 by subtracting 0.07692307692307692388352 3.019877344877345 by subtracting 0.08333333333333331935232 2.928968253968254 by subtracting 0.09090909090909089955840 2.828968253968254 by subtracting 0.10000000000000000000000 2.717857142857143 by subtracting 0.11111111111111109246976 2.592857142857143 by subtracting 0.12499999999999998951424 2.450000000000000 by subtracting 0.14285714285714284216320 2.283333333333333 by subtracting 0.16666666666666663870464 2.083333333333333 by subtracting 0.20000000000000000000000 1.833333333333333 by subtracting 0.24999999999999997902848 1.500000000000000 by subtracting 0.33333333333333327740928 1.000000000000000 by subtracting 0.49999999999999995805696 0.000000000000000 by subtracting 0.99999999999999991611392
|
|
|
Post by tenochtitlanuk on Nov 9, 2021 14:58:57 GMT -5
I've had fun before with high-precision arithmetic. See High Precision on my site. Series where the sign of each term alternates +/- are not so immediately obvious... Clearly anything where you keep adding is going to be unbounded. See my quoted page and the line 'The harmonic series is divergent, albeit quite slowly, and grows toward infinity.'
The interest is in seeing the total reaching two digit numbers and more in finite computing time.
|
|
|
Post by tenochtitlanuk on Nov 9, 2021 9:39:44 GMT -5
Anyone looking for a bit of coding fun might like to try Harmonic Series on Rosetta Code. Calculate the sum of the reciprocals of the first n natural numbers Hn = 1 + 1/2 + 1/3 + ... + 1/nEasy with LB. Try it and then take advantage of LB's number ( or string) handling qualities to display more precision. Don't look at Diga Me until you've tried it!
|
|
|
Post by tenochtitlanuk on Nov 5, 2021 16:23:03 GMT -5
Another example showing colour fill cycling through the whole range of hues, up and down.
|
|
|
Post by tenochtitlanuk on Nov 3, 2021 10:18:37 GMT -5
Just adding to Rod's post. Try the code below on your machine. Results will vary with your processor and clock speed. I graph machine processor usage in Linux System Monitor. I gave each 'notice' 5 seconds before responding. to separate the times. print "Starting a long empty loop" for i =1 to 1000000 ' next i notice "OK"
print "Pausing 5 seconds" call pause 5000
print "Sleeping 5 seconds" call sleep 5000 notice "OK"
print "Starting 5 sec timer" timer 5000, [on] wait [on] timer 0 notice "OK"
print "Starting a long empty loop" for i =1 to 1000000 ' next i notice "OK"
print "Done"
end
sub pause mil t =time$( "ms") +mil while time$( "ms") <t scan wend end sub
sub sleep ms calldll #kernel32, "Sleep",_ ms as ulong,_ ret as void end sub
|
|
|
Post by tenochtitlanuk on Nov 2, 2021 17:51:00 GMT -5
Very computer-busy ways to implement a delay. Better is probably
call Sleep 1000 'Sleep for 1000 milliseconds
Sub Sleep ms CallDLL #kernel32, "Sleep",_ ms as long,_ ret as void End Sub
|
|
|
Post by tenochtitlanuk on Nov 2, 2021 11:59:35 GMT -5
I'd encourage you to play with this example... you can easily modify horizontal and vertical scale and offset and colours.
nomainwin
WindowWidth =1000 WindowHeight = 650
open "Three sin waves" for graphics_nsb as #wg
#wg "trapclose quit"
' trig functions in LB expect radians not degrees ' convert by multiplying by pi/180 P =3.14159265 /180
' sine lies between +/-1. Scale this to +/-80 and offset vertically for each curve.
#wg "fill lightgray ; down"
call grid
for theta =0 to 4 *360 step 0.5 xS =int( 20 +theta /4 /360 *1000) ' xScreen scaled to fit window
amplitude1 =sin( theta *P) #wg "color red ; set "; xS; " 100 ; set "; xS; " "; 100 +80 *amplitude1
amplitude2 =sin( theta *P +60 *P) #wg "color green ; set "; xS; " 300 ; set "; xS; " "; 300 +80 *amplitude2
amplitude3 =sin( theta *3 *P) #wg "color blue ; set "; xS; " 500 ; set "; xS; " "; 500 +80 *amplitude3 next theta
wait end
sub grid for theta =0 to 4 *360 step 90 ' draw vertical gridline every 90 degrees. #wg "line "; int( 20 +theta /4 /360 *1000); " 0 "; int( 20 +theta /4 /360 *1000); " 600" next theta end sub
sub quit h$ close #wg end sub
|
|
|
Post by tenochtitlanuk on Nov 2, 2021 8:03:27 GMT -5
Just catching up with this- a fun project.
Caution to others- you'll need to delete the preamble lines at the start of the downloaded dictionaries, and there is an errant 'paths$' that should be 'path$'. And ld should really be set to 0 at the start? As a user of LB under Wine/Linux I always make sure datafiles use CRLF separators...
dkl... just because you don't get much reaction doesn't mean your code and messages are not appreciated! I happen to have other things on the go at the moment but it was well worth my time having a look at this. Keep posting!
|
|
|
Post by tenochtitlanuk on Nov 1, 2021 17:11:08 GMT -5
Does this do what you want? I saved your data as 'original.fil' and 'control.fil', and it wrote 'newFile.txt'.
' Read the file. If 'VN990004' present in a line, skip- otherwise write to file count =0
CR$ =chr$( 13) +chr$( 10)
open "newFile.txt" for output as #fOut2 open "original.fil" for input as #fIn do line input #fIn, row$
I =instr( row$, "VN990004") if I <>0 then cowNumber =val( mid$( row$, I +9, 6))
if found( cowNumber) then #fOut2 row$; CR$; print "."; ' showing progress.. else count =count +1 print "!"; end if
end if
loop until row$ ="" or eof( #fIn) <0 close #fIn close #fOut2
print "" print " I removed "; count; " rows of data referring to 'VN990004' but cow's number was not in 'control.fil'."
end ' _________________________________________________
function found( cN) open "control.fil" for input as #fIn2 cN$ =input$( #fIn2, lof( #fIn2)) close #fIn2 if instr( cN$, str$( cN)) then found =1 else found =0 end function
function rndChrs$( N) ' generate random alpha content for i =1 to N rndChrs$ =rndChrs$ +chr$( 65 +int( 26 *rnd( 1))) next i 'rndChrs$ ="asdfghjkl" end function
|
|