Oxygen Basic

Information => Open Forum => Topic started by: RobbeK on October 17, 2014, 01:41:52 AM

Title: A movie about A Turing -- Factor programming language
Post by: RobbeK on October 17, 2014, 01:41:52 AM
Hi all,

http://www.imdb.com/video/imdb/vi3398414105/?ref_=tt_ov_vi

... at least : a movie should have been made earlier, but :  "In the United Kingdom, computer scientist Alan Turing, famous for his contributions to mathematics and computer science, was a homosexual who chose to undergo chemical castration in order to avoid imprisonment in 1952.[23] At the time, homosexual acts between males were still illegal and homosexuality was widely considered to be a mental illness that could be treated with chemical castration.[23] Turing experienced side effects such as breast enlargement[24] and bloating of the physique.[23] He died two years later, with the inquest returning a verdict of suicide,[25] although recent research has cast doubt on this result.[26] In 2009, the then British Prime Minister Gordon Brown issued a public apology for the "appalling" treatment of Turing after an online petition seeking the same gained 30,000 signatures and international recognition.[27] He was given a posthumous Royal Pardon in December 2013."

 >:(   ---   the reward for saving 1000s of people

-------------------  and a most interesting programming language :
http://www.youtube.com/watch?v=f_0QlhYlS8g

it feels great :  it's a stack oriented language, avoiding the lisp parenses by doing everything via same --  it has the full numeric tower , OpenGL , streams and lazy lists , mapping , lambdas etc ...
2 compilers : a naive and an optimizing ..  high speed compiled code benchmarks ....


best, Rob
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 17, 2014, 12:30:16 PM
Rob,

In a strange way I can relate to Alan Turing story. My beliefs in a simple to use, cross platform BASIC solution is viewed as a sick way of thinking.  :-[  I may be wrong and the reason folks don't use SB because what they have seen looks too good to be true. (all screen shots are Photoshop'ed and none of the code really works) Who knows what goes on in the minds of those not willing to put one foot in front of another.

Title: Re: A movie about A Turing -- Factor programming language
Post by: Charles Pegge on October 17, 2014, 01:19:35 PM

Short demo of an interactive concatenative system.

"Brief" Concatenative Programming Language Demo
2011


http://www.youtube.com/watch?v=R3MNcA2dpts
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 17, 2014, 10:49:57 PM
Brief has a Lisp philosophy. Should be doable in a web interface.

 
Title: Re: A movie about A Turing -- Factor programming language
Post by: Charles Pegge on October 18, 2014, 12:36:23 AM
I think it would be very easy to reconfigure Lisp into a Cat language.

1 Place all operators on the right, before each closing bracket.

2 remove closing brackets

3 remove opening brackets and offer an optional fence marker.

Disposing of all those brackets would be a blessed relief :)
Title: Re: A movie about A Turing -- Factor programming language
Post by: RobbeK on October 18, 2014, 02:02:15 AM
Hi Charles, John ,

.... My beliefs in a simple to use, cross platform BASIC solution is viewed as a sick way ...
oh, but most people love complexities ( .. and gadgets, it gives a (false) feeling of importance  :-\

Yep, coding in (somthing like) Factor , gives a "Lisp Erlebnis / déjà-vu"   8) , and the stack a nice mechanism removing the parens --  do you remember the (iirc) Jupiter Ace home computer from the early 1980's ????  it was equipped with a Forth interpreter/compiler and outperformed in speed everything else on the market.

that Euler #1 is also a one-liner in Lisp (a quicky) :

(apply + (filter (lambda (x) (or (zero? (mod x 3)) (zero? (mod  x 5)))) (sequence 1 999)))


-------------- REPL

newLISP v.10.6.0 32-bit on Win32 IPv4/6 libffi, options: newlisp -h

>
(3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45 48 50 51 54 55 57 60
 63 65 66 69 70 72 75 78 80 81 84 85 87 90 93 95 96 99 100 102 105 108 110 111 114
 115 117 120 123 125 126 129 130 132 135 138 140 141 144 145 147 150 153 155 156
 159 160 162 165 168 170 171 174 175 177 180 183 185 186 189 190 192 195 198 200
 201 204 205 207 210 213 215 216 219 220 222 225 228 230 231 234 235 237 240 243
 245 246 249 250 252 255 258 260 261 264 265 267 270 273 275 276 279 280 282 285
 288 290 291 294 295 297 300 303 305 306 309 310 312 315 318 320 321 324 325 327
 330 333 335 336 339 340 342 345 348 350 351 354 355 357 360 363 365 366 369 370
 372 375 378 380 381 384 385 387 390 393 395 396 399 400 402 405 408 410 411 414
 415 417 420 423 425 426 429 430 432 435 438 440 441 444 445 447 450 453 455 456
 459 460 462 465 468 470 471 474 475 477 480 483 485 486 489 490 492 495 498 500
 501 504 505 507 510 513 515 516 519 520 522 525 528 530 531 534 535 537 540 543
 545 546 549 550 552 555 558 560 561 564 565 567 570 573 575 576 579 580 582 585
 588 590 591 594 595 597 600 603 605 606 609 610 612 615 618 620 621 624 625 627
 630 633 635 636 639 640 642 645 648 650 651 654 655 657 660 663 665 666 669 670
 672 675 678 680 681 684 685 687 690 693 695 696 699 700 702 705 708 710 711 714
 715 717 720 723 725 726 729 730 732 735 738 740 741 744 745 747 750 753 755 756
 759 760 762 765 768 770 771 774 775 777 780 783 785 786 789 790 792 795 798 800
 801 804 805 807 810 813 815 816 819 820 822 825 828 830 831 834 835 837 840 843
 845 846 849 850 852 855 858 860 861 864 865 867 870 873 875 876 879 880 882 885
 888 890 891 894 895 897 900 903 905 906 909 910 912 915 918 920 921 924 925 927
 930 933 935 936 939 940 942 945 948 950 951 954 955 957 960 963 965 966 969 970
 972 975 978 980 981 984 985 987 990 993 995 996 999)
>
233168
>

yesterday I coded a complete triangulation network wit 5-6 lines of Lisp code   (unique branches - no overlaps )   -- it's not special , just easy in languages like Lisp etc ...

Factor :  sadly my comp's hardware is out of date :
http://factorcode.org/factor-windows7.png

if you install  Factor , it should run in the listener just with     "spheres" run


best Rob

 
Title: Re: A movie about A Turing -- Factor programming language
Post by: Charles Pegge on October 18, 2014, 02:58:28 AM
Yes, I remember the Jupiter, but they were on the market for such a brief period, I never got round to buying one.

http://en.wikipedia.org/wiki/Jupiter_Ace

Notional Cat code:

N factorial

  inc 1 ( dec2 one? exit  dup2 mul repeat ) swap pop
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 18, 2014, 05:32:20 AM
Quote
oh, but most people love complexities ( .. and gadgets, it gives a (false) feeling of importance

I have come to the conclusion no one programs in BASIC any longer.  The only interest in BASIC is creating another interpreter because the 100+ variations that exist in one form or another aren't good enough.
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 18, 2014, 05:40:50 AM
Quote from: Rob
sadly my comp's hardware is out of date

Did you ever give Koding.com a try? (64 bit Ubuntu 14.04 LTS) FREE
Title: Re: A movie about A Turing -- Factor programming language
Post by: Charles Pegge on October 19, 2014, 02:41:00 AM
The Pentium's FPU (floating point processor) is an almost perfect cat machine.

a+(b*c)+d

fxch  st1   ' b   a   c   d
fmulp st2   ' a (b*c)   d
faddp st1   ' a+(b*c)  d
faddp st1   ' a+(b*c)+d




the FPU instructions are deployed here in a deff macro. Such macros handle all Oxygen's core floating point functions.

Code: [Select]
include "$/inc/console.inc"
indexbase 0

deff TestFormula

'a+(b*c)+d

'naive

'fxch st1 '
'fmul st2
'fadd st1
'fadd st3
'fxch st3
'fstp st0 ' drop
'fstp st0 ' drop
'fstp st0 ' drop


'appending 'p' puts the result in the specified FPU stack register (st0..st7),
'then drops st0 after the instruction,
'moving all operands up 1 position.

'compacted:   st0 st1 st2 st3

fxch  st1   ' b   a   c   d
fmulp st2   ' a (b*c)   d
faddp st1   ' a+(b*c)  d
faddp st1   ' a+(b*c)+d

end deff

float a
#show a=TestFormula(1,2,3,4)
print a
waitkey
Title: Re: A movie about A Turing -- Factor programming language
Post by: Charles Pegge on October 19, 2014, 04:03:38 AM
An earlier film on Turing:

Breaking the Code: Biography of Alan Turing (Derek Jacobi, BBC, 1996)
http://www.youtube.com/watch?v=S23yie-779k


Alan Turing: Inquest's suicide verdict 'not supportable' -2012
http://www.bbc.co.uk/news/science-environment-18561092
Title: Re: A movie about A Turing -- Factor programming language
Post by: Charles Pegge on October 19, 2014, 07:22:52 PM
Fibonacci series using the FPU stack

This is built around two instructions:

fadd
fxch


The CPU manages iteration and storage of the values into array f[]

Code: [Select]
include "$/inc/console.inc"
indexbase 0

deff FiboSeries
===============
fld1
fldz
(
 dec   ecx
 jl    exit
 fadd  'st1
 fxch  'st1
 fld   st0
 fistp qword [edx]
 add   edx, 8
 repeat
)
fstp st0
fstp st0
end deff

sys n=90
quad f[100]
ecx=n+1 : edx=@f : =FiboSeries()
print f[n-1] "/" f[n] cr f[n]/f[n-1]
waitkey
Title: Re: A movie about A Turing -- Factor programming language
Post by: RobbeK on October 20, 2014, 01:53:35 AM
Hi ,    thanks John -- forgot, but tried it now, works great !

Great Charles,  :)

It could also be written in Lisp without much problems imho.

-------------------------

;; CatSimul

(define stack nil)

(define (pop*) (pop stack))
(define (push* x) (push x stack))
(define (dup*) (push (first stack) stack))

(define (swap*)
  (let ((a (pop stack))
        (b (pop stack)))
   (push a stack)
   (push b stack)))

(define (clr*) (setq stack nil))

(define (+*) (push* (+ (pop*) (pop*))))

(define (print*) (print (pop*)))

(define (rot*)
  (let ((a (pop*))
        (b (pop*))
        (c (pop*)))
   (push* b) (push* a) (push* c)))

(define-macro (do* i f)
  (dotimes (void (eval i) )
    (dolist (j (eval f)) (eval j) )))

(define (fibo x)
  (clr*)
  (do* 2 '((push* 1L)))
  (do* x '((dup*) (rot*) (+*) ))
  (swap*) (print*) (print "  OK  ")
   )

----------------------------REPL

> (time (fibo 4000))
6457488449094817353137694901536959564441390064015134270840757759817721035903408891444947780728724174
3760741523783818897499227009742183152482019062763550798743704275106856470216307593623057388506776767
2020696704775060888952943005092911660239478668417638539538139822817039366653699227090953080068213995
2478072104995582919140702994362208777929645917401261014865952038117045259114133194933608057714170864
5783606636081941915217355115810993973945783493983844592749672661361548061615756595818944317619922097
3699176769740582063418920881445493379744229521401326215683407010162734227278277627261530663030930529
8205175744474242803310752241946621965578041310175950523161722257829248608100239121878518929967575776
6920269402348733644662725774717740924068828300186439425921761082545463164628807702653752619616157324
434040342057336683279284098590801501L  OK  78.125
-----------------
that's less than 0.1 sec (with an interpreter)

the stack is typeless here  8)   can contain strings, lambda's, numbers ...  other stacks  ???   etc...

maybe an own stack for the iterations and maybe one for the formulae (lambda's)  ...
Syntax can be completely changed by writing some syntax-macro's   ... numbers already evaluate to themselves, but function could be changed into symbols (here it are still functions)  then the parens can go, the sequence can be changed and numbers will be automatically placed on the stack     ... but as mixing data and code is no problem .....

just a simulation of course ;..   ,,   thanks for the links .. appreciated !!

best Rob

the code does

A
B
-------------------->  DUP ROT +
A+B
B   
(on the stack)

mmm, an idea -- a numeric stack processed with Oxygen - and a (slower) typeless controled by Lisp -- that should be something

-----    better syntax :


(define stack nil)
(define lambda-stack nil)
(define $cat 0)

(define (clr-lambda-stack) (setq lambda-stack nil))
 

(define-macro (cat#)
 (doargs (i)
   (if (number? i)
       (push i stack)
   (if (list? i) (push i lambda-stack)
   (let ((s (string i)))
       (cond ((= s "dup") (push (stack 0) stack))
             ((= s ".") (println (pop stack) "  ok" ))
             ((= s "drop") (pop stack))
             ((= s "+" ) (push (+ (pop stack) (pop stack)) stack ))
             ((= s "swap") (let ((a (pop stack))
                                 (b (pop stack))) (push a stack) (push b stack)))
             ((= s "do")
                 (dotimes (void (pop stack)) (eval (cons 'cat# (first lambda-stack))))
                 (clr-lambda-stack))
             ((= s "rot") (let (( a (pop stack))
                                (b (pop stack)) (c (pop stack)))
                    (push b stack) (push a stack) (push c stack)))
             ((= s "$cat") (push $cat stack))     
  )))))  )


now the only parens used are to put composed parts on a "lambda-stack" for iteration etc...
it is called recursively, but only one level / parens ...  they can be nested ....


> (cat# 1L 1L (dup rot +) 4000 do swap .)    -- all that's needed for a fibonacci


6457488449094817353137694901536959564441390064015134270840757759817721035903408891444947780728724174
3760741523783818897499227009742183152482019062763550798743704275106856470216307593623057388506776767
2020696704775060888952943005092911660239478668417638539538139822817039366653699227090953080068213995
2478072104995582919140702994362208777929645917401261014865952038117045259114133194933608057714170864
5783606636081941915217355115810993973945783493983844592749672661361548061615756595818944317619922097
3699176769740582063418920881445493379744229521401326215683407010162734227278277627261530663030930529
8205175744474242803310752241946621965578041310175950523161722257829248608100239121878518929967575776
6920269402348733644662725774717740924068828300186439425921761082545463164628807702653752619616157324
434040342057336683279284098590801501L  ok
171.875


Title: Re: A movie about A Turing -- Factor programming language
Post by: Charles Pegge on October 20, 2014, 08:03:56 AM
Hi Rob,

It seems there was no evidence  that Turing was feeling depressed and persecuted leading to suicide. He had a laboratory next to his bedroom, and he was performing experiments with gold plating, which involves electrolysis with potassium cyanide solution. It looks like an unfortunate accident. However, he might have been suicided by the security services as a perceived risk, having all those boyfriends...



I am making one minor change to the assembler, to make deff macros able to invoke other simple macros. This will greatly facilitate building stack languages around FPU instructions.

This is an experimental coding for the inner loop of a Mandelbrot plot. It saturates the FPU stack, but it does the iteration entirely in registers.

Code: [Select]
deff MandelbrotLimit
====================
  push 0
  fistp dword[esp]
  pop ecx
  fldz 'y0
  fldz 'x0
  inc  ecx
  (
   dec   ecx
   jle exit             'always exit after 'count' iterations
   fld   st0 : fmul st0 'sqx0
   fld   st2 : fmul st0 'sqy0
   fsubp st1            'sqx0-sqy0
   fadd  st3            '+x
   fld   st1            'x0
   fmul  st3            'x0*y0
   fadd  st0            '2*x0*y0
   fadd  st5            '+y
   fstp  st3            'new y0
   fst   st1            'new x0
   ; TEST LIMIT
   fmul  st0            'sq x0
   fld st2 : fmul st0   'sq y0
   faddp st1            'sqx0+sqy0
   fld st5              '4.0
   fcomip               'compare 4.0 - result ( drop 4.0 )
   fstp st0             'drop result
   ja repeat            'continue if 4.0 was greater than result
  )
  fstp st0 : fstp st0
  fstp st0 : fstp st0
  fstp st0
  push ecx
  fild dword [esp]
  pop ecx
end deff

Used in conjunction with one of Peter's GDI windows examples:
Code: [Select]
include "window.inc"
Window "MANDEL AFRICAN",620,500,4

single x,y,cx,cy,f=.004, four=4.0
sys    count=32

ClsColor 105,168,100
  For x=0 To 620
    cx=x*f-1.5
    For y=0 To 250 
      cy=1-y*f
      i=MandelbrotLimit(four, cy, cx, count)
      if i
        i=count-i
        Pixel x, y,ColorRGB(i*.4,y,i*.6)
        Pixel x, 500-y, ColorRGB(i*.4,y,i*.6)
      end if
    Next
  Next
Pause
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 20, 2014, 08:19:13 AM
Hi Charles,

Given

Code: [Select]
edx=@f-8
and

Code: [Select]
(
 add   edx, 8
 dec   ecx
 jl    exit
 fadd  'st1
 fxch  'st1
 fld   st0
 fistp qword [edx]
 repeat
)

the integer instruction flow will run at least 2 times faster thanks to UV pairability of successive add edx and dec ecx instructions which are otherwise separated by a jump back at repeat. :)
Title: Re: A movie about A Turing -- Factor programming language
Post by: Charles Pegge on October 20, 2014, 08:27:12 AM
Yes, good point, Mike.

We also have a degree of parallel operation  with CPU and FPU. Maybe we could also do something useful in the SIMD processor at the same time :)
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 20, 2014, 08:42:41 AM
Exactly, Charles.

Pairability of some simple FPU instructions with fxch makes its clock-wise cost 0. At the same time, fxch may bring the latency caused by interdependence of successive FPU instructions down to nil as well. In many cases, and especially in tricky FPU loops similar to Mandel where every clock counts, this can help improve the loop speed by some half a dozen to over a dozen CPU clocks per iteration.
Title: Re: A movie about A Turing -- Factor programming language
Post by: RobbeK on October 20, 2014, 10:49:55 AM
Hi Charles,

"an unfortunate accident"  ..  I use both KCN and the harmless K Fe(III) cyanide for my photography   (gold, platinum, copper etc ... toning) ,   a lethal dose would still be more than 0.5 g (not a few crystals flying around ) .. and even then it seems Rasputin after eating some cyanide biscuits , just walked home.   (there may be a medical reason , the KCN has to be converted in HCN first , and then it will bind the Fe in the hemoglobine of one's blood -- normally the stomac acids are more than strong enough , but ...   ?     (maybe his stomac at that moment was completely saturated with wodka  :o )

(prunes , cherries (and even more their stones) almonds also contain some cyanide , my grand-father long ago told me (he was a forrester ) that no animal sleeps under a "prune hedgerow" , it makes sick ????   


best Rob
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 21, 2014, 12:57:53 AM
Quote from: Rob
oh, but most people love complexities ( .. and gadgets, it gives a (false) feeling of importance

Here is a good example from one of the PB zombies that thinks Zale thought of him as a peer.

Code: Text
  1. ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
  2. '                                        Build with PBCC 6.0
  3. ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
  4.  
  5.     #include "\basic\include\win32api.inc"
  6.  
  7.     ' %clockit = 0  ' uncomment to run timing.
  8.  
  9. ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
  10.  
  11. FUNCTION PBmain as LONG
  12.  
  13.     #REGISTER NONE
  14.  
  15.     LOCAL src  as DWORD
  16.     LOCAL lcnt as DWORD
  17.     LOCAL pMem as DWORD
  18.     LOCAL tcnt as DWORD
  19.  
  20.     a$ = _
  21.         "Friends, Romans, countrymen, lend me your ears;"+chr$(13,10)+_
  22.         "I come to bury Caesar, not to praise him."+chr$(13,10)+_
  23.         "The evil that men do lives after them;"+chr$(13,10)+_
  24.         "The good is oft interred with their bones;"+chr$(13,10)
  25.  
  26.   #IF %DEF(%clockit)
  27.     Open "lt.txt" for Binary as #1  ' VERY BIG file of your choice
  28.       Get$ #1, lof(1), a$
  29.     Close #1
  30.     tcnt = GetTickCount
  31.   #ENDIF
  32.  
  33.     src = StrPtr(a$)
  34.  
  35.     PREFIX "! "
  36.     push src
  37.     call lines_to_array             ; call the tokenizer
  38.     mov pMem, eax                   ; returned array pointer address in variable
  39.     mov lcnt, ecx                   ; line count in variable
  40.     END PREFIX
  41.  
  42.   #IF %DEF(%clockit)
  43.     tcnt = GetTickCount - tcnt
  44.     StdOut "Timing = "+format$(tcnt)+" milliseconds"
  45.     ! jmp bye
  46.   #ENDIF
  47.  
  48.     PREFIX "! "
  49.     mov esi, pMem                   ; load pointer array into ESI
  50.     mov edi, lcnt                   ; load the line count into EDI
  51.   lbl1:
  52.     push DWORD PTR [esi]            ; write the line of text to the console
  53.     call puts                       ; make MSVCRT useful
  54.     add esi, 4                      ; increment to next pointer
  55.     sub edi, 1                      ; decrement the loop counter
  56.     jnz lbl1
  57.  
  58.     END PREFIX
  59.  
  60.   bye:
  61.     GlobalFree pMem                 ' release pointer memory here
  62.     waitkey$
  63.  
  64. End FUNCTION
  65.  
  66. ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
  67.  
  68. FUNCTION lines_to_array(ByVal src as DWORD) as DWORD
  69.  
  70.   ' --------------------------------------------------------------------------
  71.   ' in place tokenize a text file and return an array of pointers to the start
  72.   ' of each line which is terminated at the ascii 13 location with an ascii 0
  73.  
  74.   ' IN     address of source text
  75.   ' OUT 1. array of pointers address in EAX
  76.   '     2. line count in ECX
  77.  
  78.   ' address of pointer array must be released in the scope of the caller
  79.   ' using GlobalFree()
  80.   ' --------------------------------------------------------------------------
  81.  
  82.     #REGISTER NONE
  83.  
  84.     LOCAL lcnt as DWORD
  85.     LOCAL pMem as DWORD
  86.     LOCAL alen as DWORD
  87.  
  88.     PREFIX "! "
  89.  
  90.     push src
  91.     call get_lcnt           ; get the line count
  92.     mov lcnt, eax           ; store line count in variable
  93.     lea eax, [eax*4]        ; set pointer array length
  94.     mov alen, eax           ; store the array size in alen
  95.  
  96.   ; --------------------------
  97.   ; allocate the pointer array
  98.   ; --------------------------
  99.     END PREFIX
  100.     pMem = GlobalAlloc(%GMEM_FIXED or %GMEM_ZEROINIT,alen)
  101.     PREFIX "! "
  102.  
  103.     mov esi, src            ; source address in ESI
  104.     mov ebx, pMem           ; pointer array address in EBX
  105.  
  106.     mov [ebx], esi          ; load array address into 1st member of array
  107.     add ebx, 4
  108.     sub esi, 1
  109.  
  110.   lbl1:
  111.     add esi, 1
  112.     movzx eax, BYTE PTR [esi]
  113.     test eax, eax           ; test for zero
  114.     jz lbl2                 ; exit loop on zero
  115.     cmp eax, 13             ; test for ascii 13
  116.     jne lbl1                ; short loop back if not 13
  117.  
  118.     mov BYTE PTR [esi], 0   ; write terminator at ascii 13 location
  119.     add esi, 2              ; step over ascii 13 and 10
  120.     mov [ebx], esi          ; write the next line start to pointer
  121.     add ebx, 4              ; increment to next pointer
  122.     jmp lbl1                ; long loop after writing pointer
  123.  
  124.   lbl2:
  125.     mov ecx, lcnt           ; return the line count in ECX
  126.     mov eax, pMem           ; the array pointer in EAX
  127.     mov FUNCTION, eax
  128.  
  129.     END PREFIX
  130.  
  131. End FUNCTION
  132.  
  133. ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
  134.  
  135. FASTPROC get_lcnt
  136.  
  137.     PREFIX "! "
  138.  
  139.   ; --------------------------------------
  140.   ; count ascii 13 to determine line count
  141.   ; --------------------------------------
  142.     mov edx, [esp+4]                    ; the source address
  143.     sub edx, 1
  144.     xor eax, eax
  145.     jmp lbl1
  146.  
  147.   pre:
  148.     add eax, 1                          ; increment the counter
  149.   lbl1:
  150.   ; -----------
  151.   ; unroll by 4
  152.   ; -----------
  153.     add edx, 1
  154.     movzx ecx, BYTE PTR [edx]
  155.     cmp ecx, 13
  156.     je pre
  157.     test ecx, ecx
  158.     jz lbl2
  159.  
  160.     add edx, 1
  161.     movzx ecx, BYTE PTR [edx]
  162.     cmp ecx, 13
  163.     je pre
  164.     test ecx, ecx
  165.     jz lbl2
  166.  
  167.     add edx, 1
  168.     movzx ecx, BYTE PTR [edx]
  169.     cmp ecx, 13
  170.     je pre
  171.     test ecx, ecx
  172.     jz lbl2
  173.  
  174.     add edx, 1
  175.     movzx ecx, BYTE PTR [edx]
  176.     cmp ecx, 13
  177.     je pre
  178.     test ecx, ecx
  179.     jnz lbl1
  180.  
  181.   lbl2:
  182.     ret 4
  183.  
  184.     END PREFIX
  185.  
  186. END FASTPROC
  187.  
  188. ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
  189.  
  190.     DECLARE FUNCTION vcputs CDECL LIB "MSVCRT.DLL" ALIAS "puts" (BYVAL ptxt AS DWORD) AS DWORD
  191.  
  192. ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
  193.  
  194. SUB puts(BYVAL ptxt AS DWORD)
  195.  
  196.   vcputs ptxt
  197.  
  198. End SUB
  199.  
  200. ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
  201.  


Code: Script BASIC
  1. a = """
  2. Friends, Romans, countrymen, lend me your ears;
  3. I come to bury Caesar, not to praise him.
  4. The evil that men do lives after them;
  5. The good is oft interred with their bones;
  6. """
  7. SPLIT a BY "\n" TO l
  8. FOR x = 0 TO UBOUND(l)
  9.   PRINT l[x],"\n"
  10. NEXT
  11.  

Output


jrs@laptop:~/sb/sb22/test$ time scriba l2a.sb
Friends, Romans, countrymen, lend me your ears;
I come to bury Caesar, not to praise him.
The evil that men do lives after them;
The good is oft interred with their bones;


real   0m0.003s
user   0m0.003s
sys   0m0.000s
jrs@laptop:~/sb/sb22/test$


Title: Re: A movie about A Turing -- Factor programming language
Post by: Aurel on October 21, 2014, 01:38:38 AM
ha..ha...ha....
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 21, 2014, 09:49:26 AM
John,

That mysterious somebody certainly isn't such a noddy as you might think. There is only one thing that can beat assembly in terms of speed, and that thing is some more assembly.

Here are my benchmarks for splitting a 39MB bible.txt file that contains 10 copies of the Holy Bible into a string array using

i) scriba's native SPLIT();
ii) FBSL's native ArrayFromFile(); and
iii) PB's inline assembly as per your PB source.

You're falling into your own trap again. Never trade speed for "efficiency" when dealing with strings.

Code: [Select]
' SB
OPEN "bible.txt" FOR BINARY AS 1
a = INPUT(LOF(1), 1)
CLOSE 1
' Corrected by JRS:
SPLITA a BY "\n" TO l

Code: [Select]
// FBSL
DIM gtc = GetTickCount()
ARRAYFROMFILE("bible.txt", 2048) // MAX permissible length for each line is 2048 bytes
MSGBOX(, GetTickCount() - gtc & " milliseconds", "FBSL",)

.
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 21, 2014, 10:05:56 AM
My point was that I didn't spend hours writing a program that saves me a second. You have to put a value on your own time. Once again, use the right tool for the job.
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 21, 2014, 10:28:21 AM
Quote from: John
Once again, use the right tool for the job.

The big idea behind the PB code you submitted is here:

Code: [Select]
...............
  #IF %DEF(%clockit)
    tcnt = GetTickCount
    OPEN "bible.txt" FOR BINARY AS #1  ' VERY BIG file of your choice
      GET$ #1, LOF(1), a$
    CLOSE #1
  #ENDIF
...............

Had it really been meant to boil down to the four lines of the verse then the author would've simply used:

Quote from: PB Manual
PARSE start$, target$() [, {[ANY] delim$ | BINARY}]

that can do a lot more than SPLIT() and ARRAYFROMFILE() taken together.
Title: Re: A movie about A Turing -- Factor programming language
Post by: Aurel on October 21, 2014, 09:56:20 PM
well ...looks interesting...
ARRAYFROMFILE("bible.txt", 2048)
Is this array of char pointers or sort of linked list
i like syntax
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 21, 2014, 11:56:43 PM
Mike,

There is a typo in your code for SB.

SPLIT should be SPLITA

Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 22, 2014, 12:10:31 AM
Code: Script BASIC
  1. a = """
  2. Friends, Romans, countrymen, lend me your ears;
  3. I come to bury Caesar, not to praise him.
  4. The evil that men do lives after them;
  5. The good is oft interred with their bones;
  6. """
  7. SPLIT a BY "\n" TO l
  8. FOR x = 0 TO UBOUND(l)
  9.   PRINT l[x],"\n"
  10. NEXT
  11.  

Then it's in fact your typo, John. ;) I didn't intend to print out the ten copies of Holy Bible in my console per each language in question. Actually, I was more interested just in splitting them. :)

(Looks like you'd better have let it go unnoticed... :D)

.
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 22, 2014, 12:28:01 AM
Too funny!

Can you print the UBOUND value for each BASIC?
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 22, 2014, 12:32:51 AM
I can print out the UBOUNDs for SB and FBSL right away. I don't own a copy of PB though; the exe was compiled by a friend of mine. I can ask him to recompile it for me again in the evening (tomorrow morning your time).

Just gimme a second...

Here you go:

.
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 22, 2014, 12:46:29 AM
Thanks!

Quote
I don't own a copy of PB though;

I've seen copies on torrents.  ;D
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 22, 2014, 12:54:40 AM
Bob PM-ed me 10 minutes after I registered on Jose's forum. I swore I never owned a copy and wasn't in need of one. (in fact, it was an assembly issue that I was searching qualified advice on)

I don't want to break my promise, John, though I do have a copy of PBWin 10 user manual for my personal reference. :)
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 22, 2014, 01:09:29 AM
Just an observation I thought I would share. :-X  I'm not sure you could buy a legit copy based on complaints of no delivery/company response posted on the PB forum.

No need for the PB UBOUND. I'm sure it works.
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 22, 2014, 11:37:31 PM
Viral Animation of Crowd vs Rotating Beam Captivates Web (http://news.yahoo.com/video/trending-viral-animation-crowd-vs-192013463.html)
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 23, 2014, 07:36:11 AM
"This video is not available in your location due to provider license restrictions". :(

Over 90% of Belarusian net traffic is pumped via Muscovite proxies.
Title: Re: A movie about A Turing -- Factor programming language
Post by: Charles Pegge on October 23, 2014, 08:52:41 AM
Not available in the UK, either - It is probably restricted to the States.
Title: Re: A movie about A Turing -- Factor programming language
Post by: RobbeK on October 23, 2014, 09:57:36 AM
Doesn't work with a US proxy ??

http://proxyusa.org/  ...


Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 23, 2014, 09:58:12 AM
Try this LINK (http://www.washingtonexaminer.com/viral-animation-of-crowd-vs-rotating-beam-captivates-web/video/gm-5347602).
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 23, 2014, 11:01:39 AM
Thanks guys for letting me see it.

All these ragdolls "enhanced" with "traumatized" skeletal animation are absolutely stunning! They're looking so realistic at this distance!

Hypnotic complicity with the crowd seems to be the cause of the scene's pronounced viral effect. Akin to one's standing at the edge of a cliff looking down fighting one's subconscious temptation to take that final step... :o
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 23, 2014, 11:24:43 AM
Glad you finally got a chance to see it. Definitely raises the bar with animation.

Reminds me of my coffee grinder. I have the same reaction as those precious beans are ground to perfection.  :D
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 23, 2014, 02:02:52 PM
Ever caught yourself wanting to stick your finger in there? :D
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 23, 2014, 02:13:57 PM
On purpose?  ::)

This video also reminds me of music groups that throw themselves into the crowd expecting them to caught and passed around. Why would anyone do that?
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 23, 2014, 02:18:30 PM
On purpose?  ::)
Nope. Just for the hell of it. ;)

Quote
This video also reminds me of music groups that throw themselves into the crowd expecting them to caught and passed around. Why would anyone do that?
I think that's out of ecstasy (if not Ecstasy). :)
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 23, 2014, 02:40:57 PM
Quote
Nope. Just for the hell of it.

I can't type worth a shit as it is, are you sick?  :o
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 23, 2014, 03:22:58 PM
As it happens, I am not. But similar latent, subconscious phobias and phylias are often the determinants of one's general character or one's temper.

Most prominent in people of creative nature as well as masters of fine arts, in which case such latency is regarded as a norm. For example, consider Vincent van Gogh (http://en.wikipedia.org/wiki/Vincent_van_Gogh) and his cut ear:

(http://i1.ytimg.com/vi/u2X6j9k5qFc/0.jpg)

Criminally prosecutable though if publicly harmful:

(http://cs301108.userapi.com/v301108288/61c7/3zxpIL13BZE.jpg)



(http://www.chatslang.com/images/shortcuts/skype/devil.png)
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 23, 2014, 03:25:13 PM
Who am I to say what is right or wrong.

Do whatever it takes to get you there.
Title: Re: A movie about A Turing -- Factor programming language
Post by: Mike Lobanovsky on October 23, 2014, 03:43:02 PM
You mean up there or down there? :D

Never mind tho. :)
Title: Re: A movie about A Turing -- Factor programming language
Post by: JRS on October 26, 2014, 09:00:36 AM
Quote
In the absence of a great dream, pettiness prevails.

-- Dr. Peter Senge --

The problem with 90% of the BASIC programmers out there.