Author Topic: Lisp in Basic  (Read 208289 times)

0 Members and 5 Guests are viewing this topic.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #420 on: August 15, 2014, 01:16:33 AM »
Code: [Select]
SUB GetSymbol
  total = 0
  opos = ipos
  smb = 1
  slength = FALSE
GetHashNumLoop:
  IF ipos = LEN(ibuf) + 1 THEN GOTO CheckExistance
  curchar = UCASE(MID(ibuf, ipos, 1))
  IF slength = TRUE THEN
    IF curchar = "\"" THEN
      ipos += 1
      GOTO CheckExistance
    ELSE
      GOTO DoStrLiteral
    END IF
  ELSE
    IF curchar = "\"" THEN
      ipos += 1
      opos = ipos
      slength = TRUE
    END IF
  END IF
  IF INSTR(" ()'", curchar) THEN GOTO CheckExistance
DoStrLiteral:
  temp = ASC(curchar) * smb + total
  total = temp - (INT(temp / maxsymboltablesize) * maxsymboltablesize)
  temp = smb * 256
  smb = temp - (INT(temp / maxsymboltablesize) * maxsymboltablesize)
  ipos += 1
  GOTO GetHashNumLoop
CheckExistance:
  IF symbols[total] = CHR(0) THEN GOTO PutInTable
  temp = symbols[total]
  IF temp = UCASE(MID(ibuf, opos, ipos - opos + slength)) THEN
    ctype = symbol
    cvalue = total
    bsd -= 1
    EXIT SUB
  END IF
  temp = total * total
  total = temp - (INT(temp / maxsymboltablesize) * maxsymboltablesize)
  GOTO CheckExistance
PutInTable:
  IF slotsfilled = maxsymboltablesize THEN
    PRINT "ERROR: Symbol table full.\n"
    END
  END IF
  symbols[total] = UCASE(MID(ibuf, opos, ipos - opos + slength))
  ctype = symbol
  cvalue = total
  slotsfilled += 1
  bsd -= 1
END SUB

Quote
Here is Fibonacci 24 with the new version.

Is that good or bad?

.

JRS

  • Guest
Re: Lisp in Basic
« Reply #421 on: August 15, 2014, 01:24:09 AM »
Quote
Is that good or bad?

No change. That's good.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #422 on: August 15, 2014, 01:29:30 AM »
BTW symbols[total] = "" in this Sub/former GoSub doesn't work any more like it used to before. Only the new symbols[total] = CHR(0) works otherwise SBLisp hangs.

Have you changed the way ibuf is chopped/CHOMPed/[R | L]TRIMmed in GetLine or whadayacallit?


P.S. Hmmmm no you haven't... Inscrutable are the ways of the Lord!  Anyway it seems like working now, so be it. The Principle of Lazy Coding teaches us: do not touch the code that works.
« Last Edit: August 15, 2014, 01:42:33 AM by Mike Lobanovsky »

JRS

  • Guest
Re: Lisp in Basic
« Reply #423 on: August 15, 2014, 01:43:44 AM »
Code: [Select]
jrs@laptop:~/sb/sb22/sblisp$ scriba lisp.sb
SBLisp - Scheme BASIC Lisp

0]' "Thanks Mike for the fix!"
THANKS MIKE FOR THE FIX!
0](quit)
Bye!
jrs@laptop:~/sb/sb22/sblisp$

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #424 on: August 15, 2014, 01:46:18 AM »
Bye-bye! :D

See you later,

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #425 on: August 15, 2014, 01:48:55 AM »
Hi Rob,

I'm awfully sorry but I didn't quite get your message. :-[ Can you please try and put it for me in some other words?

Does that mean that you are ready to participate? :)

JRS

  • Guest
Re: Lisp in Basic
« Reply #426 on: August 15, 2014, 01:50:35 AM »
Thanks for the space and allowing me to express myself with non-standard character(s).  :D

Good-Night (morning)

RobbeK

  • Guest
Re: Lisp in Basic
« Reply #427 on: August 15, 2014, 04:19:13 AM »
The idea was writing a kind of ~Basic~ in CL  ::)

PS , there is one CL that is always forgotten, probably caused by the lack of documentation -- nevertheless it is maintained well ..  it's ManKai Common Lisp , I think it comes with ASDF onboard.   (benchmarks seem around those of GCL  -- see attachment , including those for CLISP (the green one)   -- bytecode + GNU Lightning JIT.

and another interesting reading ...
http://www.flownet.com/ron/papers/lisp-java.pdf
"Erann Gat (Ron Garret) of NASA's Jet Propulsion Lab. A short study showing Lisp programs were shorter, took less time to develop, and actually ran faster than the same programming tasks in C++, let alone Java:"

(ps : the NAVEX code for the Space Shuttle is written in Lisp too )

best Rob
 

.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #428 on: August 15, 2014, 05:01:43 AM »
!!! COOL !!! TERRIFIC !!!

Rob, you're a genius! It hasn't been done ever before to the best of my knowledge.

IMO you should choose the fastest LISP available with the native code compilation capability.

Hehe man isn't that gonna be a real something! A BASIC with 1000-digit integers both sides of 0 and native compilation into the bargain...

You'll be carved in stone next to the presidents in Mount Rushmore! ;D


jack

  • Guest
Re: Lisp in Basic
« Reply #429 on: August 15, 2014, 06:36:17 AM »

RobbeK

  • Guest
Re: Lisp in Basic
« Reply #430 on: August 15, 2014, 07:08:14 AM »
@ Jack   --  perfect starter !!!  thank you ( i only found a pascal written in Scheme to cheat a little ).

@ Mike  -- you can turn off those bignum's in CL  to get faster native code , and if you wish you can write non-variadic and "typed" code too -- no problem
Attached something special --  it's my Fibonacci definition -- , the assignment of the variables is done in parallel here (Lisp has such things   p.e.  "let" is parallel assigment ;   "let*" is serial assignment   --  here it is about psetf  (or psetq)  this means something as :
a = 4
b = 5

& then a=b : b=a  resulting in

a = 5
b = 4   8)     --  cool not ,    the basic beginners mistake corrected !!!

best Rob



.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #431 on: August 15, 2014, 07:16:15 AM »
What's the size of gazonk0.o file?

Faster?! Faster than 20 msec for the 10000th Fibonacci number?!! What for?!!! :D
« Last Edit: August 15, 2014, 07:37:50 AM by Mike Lobanovsky »

jack

  • Guest
Re: Lisp in Basic
« Reply #432 on: August 15, 2014, 07:31:58 AM »
RobbeK,
is this the correct behavior of your fib function?
Quote
> (fib 3)
2
> (fib 3)
8
> (fib 3)
34
> (fib 3)
144
> (fib 3)
610

JRS

  • Guest
Re: Lisp in Basic
« Reply #433 on: August 15, 2014, 08:03:18 AM »
Mike,

What does this new SBLisp structure do to our LISP in BASIC common effort ? Are you still sticking with the QB format?

Code: [Select]
IF INSTR(" ()'", curchar) THEN GOTO CheckExistance

Shouldn't this be ...

Code: [Select]
IF INSTR(" ()'", curchar) <> undef THEN GOTO CheckExistance

John
« Last Edit: August 15, 2014, 08:19:05 AM by John »

RobbeK

  • Guest
Re: Lisp in Basic
« Reply #434 on: August 15, 2014, 08:08:30 AM »
OOps , Jack ...

seems I hit an iceberg -- it starts accumulating things (?)  -- what's happening here ... ???

attached, a solution  --  does things parallel too, and it's even faster


(strange what happened here with the psetq / psetf )

best Rob

.