Author Topic: Newbie Question ..  (Read 9016 times)

0 Members and 1 Guest are viewing this topic.

JRS

  • Guest
Re: Newbie Question ..
« Reply #15 on: June 14, 2014, 11:49:46 AM »
Quote from: Mike
If it ever happens to you, just tell John or me. We will go there and tear them to pieces.




Mike Lobanovsky

  • Guest
Re: Newbie Question ..
« Reply #16 on: June 14, 2014, 01:38:07 PM »
... this diametrically opposite language ...

Hehe,

Up till now I thought "esoteric" would be the mildest term to apply here but Charles certainly beats me to it with his "diametrically opposite language". Oh those Brits...  :D

May I suggest "perpendicular"? :D

Charles Pegge

  • Guest
Re: Newbie Question ..
« Reply #17 on: June 14, 2014, 02:25:06 PM »
Perplexiculiar ? :)

Lisp may be strange to us because it is not within the Fortran lineage. But the syntax is absurdly simple:

A Lisp expression:

(    operator      zero or more operands ...    )

A Lisp operand can be a number, a quote or a name or another expression.

« Last Edit: June 14, 2014, 02:37:47 PM by Charles Pegge »

Mike Lobanovsky

  • Guest
Re: Newbie Question ..
« Reply #18 on: June 14, 2014, 02:53:59 PM »

Charles Pegge

  • Guest
Re: Newbie Question ..
« Reply #19 on: June 14, 2014, 10:42:54 PM »
Actually, some block-structure makes a huge difference to readability:

Example: a multidimensional hypoteneuse:

  ( let hypot "
    ( sqrt
      ( + (next) ( * item item ) )
    )
  ")

  ( hypot 3 4 )  ;5
  ( hypot 1 3 5 1 ) ;6
« Last Edit: June 16, 2014, 04:47:24 AM by Charles Pegge »

Mike Lobanovsky

  • Guest
Re: Newbie Question ..
« Reply #20 on: June 15, 2014, 03:41:32 AM »
Hmmmm Charles,

Is (next) a formal indication that the hypot macro is a "variadic loop" (don't know how to better put it)?

I'm a little scared to imagine what the Toy interpreter would look like if ported to Lisp...

Charles Pegge

  • Guest
Re: Newbie Question ..
« Reply #21 on: June 15, 2014, 04:11:45 AM »
I have one brewing :)

(next) pulls an  "item" out of the parameter buffer, or terminates the iteration when the buffer is empty.

This is not Common-Lisp, I hasten to add

A simpler 2d hypot looks like this


  ( let hypot "x y
    ( sqrt
      ( + ( * x x ) ( * y y ) )
    )
  ")

« Last Edit: June 16, 2014, 04:46:41 AM by Charles Pegge »

RobbeK

  • Guest
Re: Newbie Question ..
« Reply #22 on: June 15, 2014, 05:54:22 AM »
Hi all,

Thanks John , Mike  --  I feel safer now, consequently I will make a lot of trouble next time when there  ;)

The classic variadics :
 
(define (foo)
  (doargs (i) (print i " ")))

(foo 1 2 3) -> 1 2 3

(define (foo L)
 (dolist (i L) (print i " ")))

(foo (list 1 2 3)) -> 1 2 3

(map print (list 1 2 3))  -> 123    (no spaces, to fix this an anonymous function is needed)

(map (lambda(x) (print x " ")) (list 1 2 3)) -> 1 2 3

the glorious currying function !!!

(map (curry print " ") (list 1 2 3))  -> 1 2 3

the manual says : curry :::  Returns a function which will call FUNCTION passing it INITIAL-ARGS and then any other args. (funcall (curry #'list 1) 2) ==> (list 1 2)  .. iirc Mr Curry was a math professor (not sure)  .. in math language  (curry f(x,y,...)) = fx(y,....)

Doing sequential things variadic

(apply + (list 1 2 3))  -> 6

works of course for own written definitions :

 

like in :

(define (prime? x)
  (= 1 (length (factor x))))

(map prime? (list 1 2 3)) -> (nil true true)

so: setting up a boolean hash table for some primes :

(define prime-hash-index  (map prime? (sequence 1 100000)))   -- that's all   :-*

But all this magic is orthogonal on anything a processor understands and for this reason (mainly , there are some technical reasons making (for me) interpreted Lisp more interesting than compiled), the combinations with a compiler like O2,C whatever can be super additive .

As an example something I was curious about -- an extended Fibonacci -
While Fib considered the mapping (a b) -> (a a+b) , I expanded it to (a b) -> (a f(a,b))
In the program you can see one of the powertools (eval-script ... ) ; the math part is nothing (lines on NextFib) )
I should have written it variadic , but it will take less than a minute to convert to program for complex Fib numbers, or even Fib numbers of any dimension.

(ps the stories like that the Steel Bank Common Lisp compiler for common Lisp and the mysterious STALIN compiler for Scheme outperform C is imho wishful thinking --   use and a compiler and an interpreter , that's real power !! )

best Rob


oops , forgot : the mapping ->(b  (a+b)/n)  for n > 0

n < 2  ::-> inf
n=2 ::-> 2/3
n>2 ::->0

n=1 the classic Fib numbers


.
« Last Edit: June 15, 2014, 06:09:31 AM by RobbeK »

Mike Lobanovsky

  • Guest
Re: Newbie Question ..
« Reply #23 on: June 15, 2014, 06:24:47 AM »
@Charles:

Quote
(    operator      zero or more operands ...    )
.........................
I have one brewing :)

If my memory doesn't slip me, long long ago when there was no OxygenBasic yet, your original assembler used to employ polish notation that may still be buried in the depths of O2H now in the form of some sort of an IDL. Isn't that why you're so fascinated with the possibilities of Lisp? :)

@Rob:

New Lisp seems to employ lots of parentheses in the user code. Does your editor highlight matching parentheses for you?

RobbeK

  • Guest
Re: Newbie Question ..
« Reply #24 on: June 15, 2014, 07:18:28 AM »
Hi Mike,

The one I like the most is http://www.daansystems.com/lispide/    (matching parantheses highlighting + syntax colouring (NewLisp, Common Lisp  and some others ).
NewLispEdit is good, but on my computer things may getting slow (after a few hundred lines of source)  - it runs interpreted in NewLisp and uses the Swing Java guiserver ).
There's also ZionEdit , it does the matching paranth. , but the syntax colouring is Common Lisp not NewLisp.
There's Geany , I think it's possible to include the a list with NewLisp commands for highlighting purposes, matching paranth. on board and you can set up commands for make/build/run -- CLisp syntax is already included, NewLisp not.
For CLisp there was VisualCLisp (someone in Poland iirc) , it's gone however still downloadable with the Wayback Machine ..
(CLisp imho still is interesting - very good FFI doing both cdecl and stdc -- floats upto over 3000 digits - Unlimited Length Integers , consequently slow (soft floats) ,  interpreted and compiled mode (bytecode + GNU lightning JIT ).  It comes with a primitive REPL (from the command line, running in a Terminal) - I wrote the necessary Japi bindings and an O² DLL making it possible to access flat memory  (if someone wants these, just ask ).
Probably Eclipse etc.. has plug-ins to do so, but I do not like mega-systems  ...
There's also Emacs , but again I'm too lazy to learn it ... (it's too much)
There's Lisp in a box , LispBox and LispStick with complete environments , but see the line(s) above ...
There are things for Visual Studio,  but ... 

best Rob

Mike Lobanovsky

  • Guest
Re: Newbie Question ..
« Reply #25 on: June 15, 2014, 07:53:08 AM »
Hi Rob,

The choice looks impressive.

Quote
on my computer things may getting slow (after a few hundred lines of source)

May happen if it's based on a standard richedit control with syntax highlighting implemented as continuous on-the-fly translation of plain text to the native rich text format. Not the best solution for a professional IDE IMHO.

Thanks for the feedback anyway. :)

Aurel

  • Guest
Re: Newbie Question ..
« Reply #26 on: June 15, 2014, 11:00:50 AM »
Hmm Lisp....  ;D

.

JRS

  • Guest
Re: Newbie Question ..
« Reply #27 on: June 15, 2014, 11:23:42 AM »
Sorry that you can't understand me, I'm disabled and speak with a lisp impediment.  ;D

Charles Pegge

  • Guest
Re: Newbie Question ..
« Reply #28 on: June 16, 2014, 03:43:05 AM »
Hi Mike,

I created an interpreted  reverse-polish language called R$ which may be still around on Josés forum. RP languages are okay for writing, but trying to read them back boggles the mind :)

Attempting to represent types, and cleanly interface DLLs also breaks the minimalist principles of such languages.



Rob,

This is how I would implement an average function:

Code: [Select]
( let average "
  ( eval
    ( let n 0 )
    ( /
      ( +
        (next) (incr n)
        item
      )
      n
    )
  )
")

( average 1 2 3 4 5 ) (cr) ;3

hmm .. that's five levels of brackets!

A more complex example: building a list of primes:

Code: [Select]
( let primes " c
  ( eval
    ( let p '1 2 3' )
    ( let v 4     )
    ( let n 2     )
    ( let d )
    ( eval
      ( set n 2 )
      ( loop ( eval
        ( set d ( getmid p n 1 ) )
        ( if d
          ( )
          ( eval
            ( setmid p 0 0 v )
            (exit)
          )
        )
        ( if ( == 0 ( mod v d ) )
          ( eval
            (exit)
          )
        )
        ( incr n )
      ) )
      ( incr v )
      ( iter c )
    )
  p
  )
")
( primes 50 ) (cr) ; 1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53

John,

In some old texts, (I have an 1830s Bible like this) the lowercase 's' is almost identical to 'f'.

It lookf very ftrange when you fee it

« Last Edit: June 16, 2014, 04:05:07 AM by Charles Pegge »

Mike Lobanovsky

  • Guest
Re: Newbie Question ..
« Reply #29 on: June 16, 2014, 04:05:22 AM »
I'm disabled and speak with a lisp impediment.  ;D

Hehe,

Come to think of it, "lisp" certainly isn't an euphonic name for a language. If I understand correctly, "lisp" is an impediment when someone would speak as if he had his front teeth knocked out.

:)

(Charles: something's telling me that Malleus Maleficarum would be a better treatise to look for the sources and occurences of this impediment)
« Last Edit: June 16, 2014, 04:14:23 AM by Mike Lobanovsky »