Author Topic: Lisp in Basic  (Read 226960 times)

0 Members and 7 Guests are viewing this topic.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #180 on: August 05, 2014, 07:05:58 PM »
OK John. Going off to bed too. See you tomorrow.

JRS

  • Guest
Re: Lisp in Basic
« Reply #181 on: August 05, 2014, 07:33:21 PM »
For now, ALL loaded SBLisp scripts must have the filename in UPPER CASE.

Wasn't that easy?  ;D

After trying it ...

FYI: Latest code on Bitbucket.

Code: [Select]
jrs@laptop:~/sb/sb22/sblisp$ scriba lisp.sb
Initializing Memory...
Initializing Lisp Environment...
LISP in BASIC v1.3 by Arthur Nunes-Harwitt
0](load (quote FF.SCM)
1]
ERROR: Read.
0]

The SBLisp script.
Code: [Select]
(define factorial (lambda (n)
(if (<= n 0)
1
(* n (factorial (- n 1))))))

(factorial 8)

Well, at least we got by the SB OPEN.

« Last Edit: August 05, 2014, 07:57:53 PM by John »

JRS

  • Guest
Re: Lisp in Basic
« Reply #182 on: August 05, 2014, 07:49:49 PM »
Quote from: Pritchard (aka Moe) - FreeBASIC forum
Not bad source at all. LISP is simple, but I still wouldn't know how to implement it in QBASIC

Maybe the other remaining stooge will clue him in.  :P

@Pritchard - All I'm hearing from the FB boys is swishing sounds.  ;D

JRS

  • Guest
Re: Lisp in Basic
« Reply #183 on: August 05, 2014, 09:33:18 PM »
Testing against the gold standard.

Code: [Select]
jrs@laptop:~/sb/sb22/sblisp$ mit-scheme
MIT/GNU Scheme running under GNU/Linux
Type `^C' (control-C) followed by `H' to obtain information about interrupts.

Copyright (C) 2014 Massachusetts Institute of Technology
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Image saved on Saturday May 17, 2014 at 2:39:25 AM
  Release 9.2 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 || Edwin 3.116

1 ]=> (load (quote FF.SCM))

;The object ff.scm, passed as an argument to merge-pathnames, is not a pathname.
;To continue, call RESTART with an option number:
; (RESTART 1) => Return to read-eval-print level 1.

2 error>

What? The file name is FF.SCM not ff.scm.

You would think someone other than Mike, Charles or Dave would have come forward an admitted to using SB.


.
« Last Edit: August 05, 2014, 10:40:39 PM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #184 on: August 06, 2014, 06:41:18 AM »
Hi John,

For now, ALL loaded SBLisp scripts must have the filename in UPPER CASE.

Wasn't that easy?  ;D
Well, this is much more restrictive than the palliation that I suggested. Now SBLisp and "the gold standard" are worthy of one another - both are dumb as hell.

Quote
jrs@laptop:~/sb/sb22/sblisp$ scriba lisp.sb
Initializing Memory...
Initializing Lisp Environment...
LISP in BASIC v1.3 by Arthur Nunes-Harwitt
0](load (quote FF.SCM)
1]
ERROR: Read.
0]
Wait wait, but where's the closing parenthesis, may I ask?

Quote from: BITBUCKET
GetLine:
  IF lispfilenum = 0 THEN
    PRINT LTRIM(FORMAT("%~##~", oparen)), "]"
    LINE INPUT ibuf
    ibuf = CHOMP(ibuf)
    ipos = 1
  ELSE
    IF NOT EOF(lispfilenum) THEN
      LINE INPUT# lispfilenum, ibuf
      PRINT ibuf
      ipos = 1
    END IF
  END IF
  bsd -= 1
  RETURN
John, you're downright ignoring my messages:

Code: [Select]
IF NOT EOF(LispFileNum) THEN
LINE INPUT# LispFileNum, I
I = CHOMP(I)
PRINT I, "\n"
IPOS = 1
END IF
Please correct the Bitbucket sources and get your linuxoid SBLisp up and running at last. ;)

Quote
Well, at least we got by the SB OPEN.
Not "we" but "I". As for me, I got the Windows scriba.exe+lisp.sb reading and executing LISP files 48 hours ago. :)

JRS

  • Guest
Re: Lisp in Basic
« Reply #185 on: August 06, 2014, 07:29:55 AM »
Quote
Not "we" but "I". As for me, I got the Windows scriba.exe+lisp.sb reading and executing LISP files 48 hours ago.

I'm jelous. 

RobbeK

  • Guest
Re: Lisp in Basic
« Reply #186 on: August 06, 2014, 09:38:11 AM »
Ah, thanks Mike  ...

Yes, it was a deduction from your name in belarusian ..  did not know about the Ukranian either .
(the only thing I knew was that very rarely the Arsenal plant (cameras and lenses) put Киïв on their gear and not Киев  .. very rare and expensive now .. collector's items ...  )

gazonk...   heart it before, but don't remember ..   (1/1000000 th of a sec the Russian word for spy-glass came into my mind -- of course not related   8) )

best Rob

JRS

  • Guest
Re: Lisp in Basic
« Reply #187 on: August 06, 2014, 09:45:41 AM »
Getting closer.

Code: [Select]
jrs@laptop:~/sb/sb22/sblisp$ scriba lisp.sb
Initializing Memory...
Initializing Lisp Environment...
LISP in BASIC v1.3 by Arthur Nunes-Harwitt
0](load (quote FF.SCM))
FF.SCM  1
(define factorial (lambda (n)
(if (<= n 0)
1
(* n (factorial (- n 1))))))
FACTORIAL

(factorial 8)
40320


ERROR: Read.
ERROR: Problem in file FF.SCM
0]

FF.SCM
Code: [Select]
(define factorial (lambda (n)
(if (<= n 0)
1
(* n (factorial (- n 1))))))

(factorial 8)

If I remove all blank lines from the end of the script except one, this is what I get.

Code: [Select]
jrs@laptop:~/sb/sb22/sblisp$ scriba lisp.sb
Initializing Memory...
Initializing Lisp Environment...
LISP in BASIC v1.3 by Arthur Nunes-Harwitt
0](load (quote FF.SCM))
FF.SCM  1
(define factorial (lambda (n)
(if (<= n 0)
1
(* n (factorial (- n 1))))))
FACTORIAL

(factorial 8)
40320

ERROR: Problem in file FF.SCM
0]

« Last Edit: August 06, 2014, 10:04:48 AM by John »

JRS

  • Guest
Re: Lisp in Basic
« Reply #188 on: August 06, 2014, 10:09:50 AM »
Success!

It seems you can't have any blank lines at the end of the script.

Code: [Select]
jrs@laptop:~/sb/sb22/sblisp$ scriba lisp.sb
Initializing Memory...
Initializing Lisp Environment...
LISP in BASIC v1.3 by Arthur Nunes-Harwitt
0](load (quote FF.SCM))
FF.SCM  1
(define factorial (lambda (n)
(if (<= n 0)
1
(* n (factorial (- n 1))))))
FACTORIAL

(factorial 8)
40320
T
0]

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #189 on: August 06, 2014, 10:36:47 AM »
Congrats John! :)

FYI:

1. An alternative way to denote literals is to prepend them with a single quote (apostrophe) '. Thus

Code: [Select]
(load (quote test.lisp))
may be written as

Code: [Select]
(load 'test.lisp)
to the same effect.

2. There's no way to print a new line or a space now. I'm using

Code: [Select]
(print '_)
for a space but I don't know how to enforce a new line. Seems like the PRINT procedure needs to be improved on. Also, currently there's no way to suppress printed output of intermediate evaluations so there may be meaningless garbage in the console.

JRS

  • Guest
Re: Lisp in Basic
« Reply #190 on: August 06, 2014, 10:49:17 AM »
It would be great to get this stuff posted to the Bitbuket issue tracker.


Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #191 on: August 06, 2014, 10:54:05 AM »
wat?

:D

A tip:

save the following as rectest.lisp

Code: [Select]
(define rectest (lambda (x)
(cond ((<= x (* 1000)) (print x) (print '_) (rectest (+ x 1))))
))

(rectest 1)

and watch LISP recursion in your console. Note also the GC START GC DONE occurences at the points where LISP auto-garbage-collects its memory for deeper and deeper recursion. :)

JRS

  • Guest
Re: Lisp in Basic
« Reply #192 on: August 06, 2014, 11:00:55 AM »
Cool !

It seemed to execute almost instantaneously.

Code: [Select]
jrs@laptop:~/sb/sb22/sblisp$ scriba lisp.sb
Initializing Memory...
Initializing Lisp Environment...
LISP in BASIC v1.3 by Arthur Nunes-Harwitt
0](load (quote RECTEST.LISP))
RECTEST.LISP  1
(define rectest (lambda (x)
(cond ((<= x (* 1000)) (print x) (print '_) (rectest (+ x 1))))
))
RECTEST

(rectest 1)
1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16_17_18_19_20_21_22_23_24_25_26_27_28_29_30_31_32_33_34_35_36_37_38_39_40_41_42_43_44_45_46_47_48_49_50_51_52_53_54_55_56_57_58_59_60_61_62_63_64_65_66_67_68_69_70_71_72_73_74_75_76_77_78_79_80_81_82_83_84_85_86_87_88_89_90_91_92_93_94_95_96_97_98_99_100_101_102_103_104_105_106_107_108_109_110_111_112_113_114_115_116_117_118_119_120_121_122_123_124_125_126_127_128_129_130_131_132_133_134_135_136_137_138_139_140_141_142_143_144_145_146_147_148_149_150_151_152_153_154_155_156_157_158_159_160_161_162_163_164_165_166_167_168_169_GC START GC done.
170_171_172_173_174_175_176_177_178_179_180_181_182_183_184_185_186_187_188_189_190_191_192_193_194_195_196_197_198_199_200_201_202_203_204_205_206_207_208_209_210_211_212_213_214_215_216_217_218_219_220_221_222_223_224_225_226_227_228_229_230_231_232_233_234_235_236_237_238_239_240_241_242_243_244_245_246_247_248_249_250_251_252_253_254_255_256_257_258_259_260_261_262_263_264_265_266_267_268_269_270_271_272_273_274_275_276_277_278_279_280_281_282_283_284_285_286_287_288_289_290_291_292_293_294_295_296_297_298_299_300_301_302_303_304_305_306_307_308_309_310_311_312_313_314_315_316_317_318_319_320_321_322_323_324_325_326_327_328_329_330_331_332_333_334_335_336_337_338_339_GC START GC done.
340_341_342_343_344_345_346_347_348_349_350_351_352_353_354_355_356_357_358_359_360_361_362_363_364_365_366_367_368_369_370_371_372_373_374_375_376_377_378_379_380_381_382_383_384_385_386_387_388_389_390_391_392_393_394_395_396_397_398_399_400_401_402_403_404_405_406_407_408_409_410_411_412_413_414_415_416_417_418_419_420_421_422_423_424_425_426_427_428_429_430_431_432_433_434_435_436_437_438_439_440_441_442_443_444_445_446_447_448_449_450_451_452_453_454_455_456_457_458_459_460_461_462_463_464_465_466_467_468_469_470_471_472_473_474_475_476_477_478_479_480_481_482_483_484_485_486_487_488_489_490_491_492_493_494_495_496_497_498_499_500_501_502_503_504_505_506_507_508_509_GC START GC done.
510_511_512_513_514_515_516_517_518_519_520_521_522_523_524_525_526_527_528_529_530_531_532_533_534_535_536_537_538_539_540_541_542_543_544_545_546_547_548_549_550_551_552_553_554_555_556_557_558_559_560_561_562_563_564_565_566_567_568_569_570_571_572_573_574_575_576_577_578_579_580_581_582_583_584_585_586_587_588_589_590_591_592_593_594_595_596_597_598_599_600_601_602_603_604_605_606_607_608_609_610_611_612_613_614_615_616_617_618_619_620_621_622_623_624_625_626_627_628_629_630_631_632_633_634_635_636_637_638_639_640_641_642_643_644_645_646_647_648_649_650_651_652_653_654_655_656_657_658_659_660_661_662_663_664_665_666_667_668_669_670_671_672_673_674_675_676_677_678_679_GC START GC done.
680_681_682_683_684_685_686_687_688_689_690_691_692_693_694_695_696_697_698_699_700_701_702_703_704_705_706_707_708_709_710_711_712_713_714_715_716_717_718_719_720_721_722_723_724_725_726_727_728_729_730_731_732_733_734_735_736_737_738_739_740_741_742_743_744_745_746_747_748_749_750_751_752_753_754_755_756_757_758_759_760_761_762_763_764_765_766_767_768_769_770_771_772_773_774_775_776_777_778_779_780_781_782_783_784_785_786_787_788_789_790_791_792_793_794_795_796_797_798_799_800_801_802_803_804_805_806_807_808_809_810_811_812_813_814_815_816_817_818_819_820_821_822_823_824_825_826_827_828_829_830_831_832_833_834_835_836_837_838_839_840_841_842_843_844_845_846_847_848_849_GC START GC done.
850_851_852_853_854_855_856_857_858_859_860_861_862_863_864_865_866_867_868_869_870_871_872_873_874_875_876_877_878_879_880_881_882_883_884_885_886_887_888_889_890_891_892_893_894_895_896_897_898_899_900_901_902_903_904_905_906_907_908_909_910_911_912_913_914_915_916_917_918_919_920_921_922_923_924_925_926_927_928_929_930_931_932_933_934_935_936_937_938_939_940_941_942_943_944_945_946_947_948_949_950_951_952_953_954_955_956_957_958_959_960_961_962_963_964_965_966_967_968_969_970_971_972_973_974_975_976_977_978_979_980_981_982_983_984_985_986_987_988_989_990_991_992_993_994_995_996_997_998_999_1000_()
T
0]

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #193 on: August 06, 2014, 11:02:44 AM »
Fine! Just make it print GC start in lowercase for consistency with GC done.

And with this version of rectest.lisp:

Code: [Select]
(define rectest (lambda (x)
(cond ((<= x (* 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000)) (rectest (+ x 1))))
))

(rectest 1)

you can shoot your eternal enemy Pritchard of FreeBASIC dead making his dream come true as your BASIC LISP counts recursively to 1E+30 + 1 autocleaning its memory in the process.

:D

JRS

  • Guest
Re: Lisp in Basic
« Reply #194 on: August 06, 2014, 11:21:23 AM »
I don't have time for idiots anymore. Pritchard of FreeBASIC is in his own world.