Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hello, protist.

This is second time I saw the name 'High Order Perl'. It took me much time to remember the days with common lisp, but I tried anyway. I wonder what does mit classes uses for lisp? It seems different from common lisp...

Tested with clisp.

(defun sum_from_to(TERM from NEXT to) (IF (> from to) 0 (+ (funcall TERM from) (sum_from_to TERM (funcall NEXT from) NEXT to)))) (defun addone (c) (+ 1 c)) (defun self(x) x) (defun square (A) (* A A)) (defun sum-int (A B) (sum_from_to #'self A #'addone B)) (defun sum-sq(A B) (sum_from_to #'square A #'addone B)) (print (sum-int 3 5)) (print (sum-sq 3 5))
And exact same migration from list to perl would work.
#!/usr/bin/perl use strict; use warnings; use feature qw(say); sub sum_from_to{ my ($TERM, $from, $NEXT, $to)=@_; if( $from > $to ){ 0; } else { $TERM->($from) + sum_from_to( $TERM, $NEXT->($from), $NEXT, $to ); } } sub addone{ return 1 + $_[0]} sub self{ return $_[0]} sub square{ return $_[0] * $_[0]} sub sum_int { my($A,$B)=@_; sum_from_to( \&self, $A, \&addone, $B); } sub sum_sq { my($A,$B)=@_; sum_from_to( \&square, $A, \&addone, $B); } say sum_int(3,5); say sum_sq(3,5);

In reply to Re: PERLISP meditations by remiah
in thread PERLISP meditations by protist

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (7)
    As of 2018-04-23 10:11 GMT
    Find Nodes?
      Voting Booth?