Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
functional code in php
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
zermelo  
View profile  
 More options Feb 10, 12:09 pm
Newsgroups: comp.lang.lisp
From: zermelo <zerm...@invalid.spam>
Date: Fri, 10 Feb 2012 17:09:35 +0000 (UTC)
Local: Fri, Feb 10 2012 12:09 pm
Subject: functional code in php
Hi,

I have to do a work in php, but I would like to write functional code as
much as possible. Anyone knows libraries/references where I can look for?

Thanks

ps I post here because perhaps some lisper has had my same problem and
has tested various strategies.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex Mizrahi  
View profile  
 More options Feb 10, 1:44 pm
Newsgroups: comp.lang.lisp
From: Alex Mizrahi <alex.mizr...@gmail.com>
Date: Fri, 10 Feb 2012 20:44:42 +0200
Local: Fri, Feb 10 2012 1:44 pm
Subject: Re: functional code in php

> I have to do a work in php, but I would like to write functional code as
> much as possible.

Why? It doesn't make any sense.

And what is 'functional code'? Some people think that it is about
high-order functions, while others -- lack of side effects, immutable data.

It doesn't make any sense to write functional code if you don't know
what it is and why you need it.

> Anyone knows libraries/references where I can look for?

http://php.net/manual/en/functions.anonymous.php

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
namekuseijin  
View profile  
 More options Feb 10, 1:59 pm
Newsgroups: comp.lang.lisp
From: namekuseijin <namekusei...@gmail.com>
Date: Fri, 10 Feb 2012 10:59:47 -0800 (PST)
Local: Fri, Feb 10 2012 1:59 pm
Subject: Re: functional code in php
On Feb 10, 4:44 pm, Alex Mizrahi <alex.mizr...@gmail.com> wrote:

> > I have to do a work in php, but I would like to write functional code as
> > much as possible.

> Why? It doesn't make any sense.

> And what is 'functional code'? Some people think that it is about
> high-order functions, while others -- lack of side effects, immutable data.

> It doesn't make any sense to write functional code if you don't know
> what it is and why you need it.

moreover, it doesn't make any sense to write in PHP specifically.
It's a dog of a language and barely holds together for ugly imperative
programming, let alone other paradigms...

> > Anyone knows libraries/references where I can look for?

> http://php.net/manual/en/functions.anonymous.php

just look at that!

class Cart
{
    const PRICE_BUTTER  = 1.00;
    const PRICE_MILK    = 3.00;
    const PRICE_EGGS    = 6.95;

    protected $products = array();

    public function add($product, $quantity)
    {
        $this->products[$product] = $quantity;
    }

    public function getQuantity($product)
    {
        return isset($this->products[$product]) ? $this-

>products[$product] :

               FALSE;
    }

    public function getTotal($tax)
    {
        $total = 0.00;

        $callback =
            function ($quantity, $product) use ($tax, &$total)
            {
                $pricePerItem = constant(__CLASS__ . "::PRICE_" .
                    strtoupper($product));
                $total += ($pricePerItem * $quantity) * ($tax + 1.0);
            };

        array_walk($this->products, $callback);
        return round($total, 2);
    }

}

it looks like the bastard son after some orgy full of perls, javas,
pythons and C... functional programming into that mix won't matter at
all...

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
zermelo  
View profile  
 More options Feb 10, 3:38 pm
Newsgroups: comp.lang.lisp
From: zermelo <zerm...@invalid.spam>
Date: Fri, 10 Feb 2012 20:38:43 +0000 (UTC)
Local: Fri, Feb 10 2012 3:38 pm
Subject: Re: functional code in php

On Fri, 10 Feb 2012 10:59:47 -0800, namekuseijin wrote:
> On Feb 10, 4:44 pm, Alex Mizrahi <alex.mizr...@gmail.com> wrote:
>> > I have to do a work in php, but I would like to write functional code
>> > as much as possible.

>> Why? It doesn't make any sense.

>> And what is 'functional code'? Some people think that it is about
>> high-order functions, while others -- lack of side effects, immutable
>> data.

>> It doesn't make any sense to write functional code if you don't know
>> what it is and why you need it.

For functional code, I mean closures, map, filter, reduce and similar
Lisp-like functions. I have searched the official documentation, but I
don't see them. Maybe there exists some external library...any help?

I don't like php, but my boss wants it. So I was guessing whether someone
here had a remedy to alleviate the pain.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Feb 10, 3:41 pm
Newsgroups: comp.lang.lisp
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Fri, 10 Feb 2012 21:41:25 +0100
Local: Fri, Feb 10 2012 3:41 pm
Subject: Re: functional code in php

zermelo <zerm...@invalid.spam> writes:
> I don't like php, but my boss wants it. So I was guessing whether someone
> here had a remedy to alleviate the pain.

PHP 5 even has closures, IIRC.  So you can start to apply Greenspun Tenth
Law right now.

--
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
zermelo  
View profile  
 More options Feb 10, 4:06 pm
Newsgroups: comp.lang.lisp
From: zermelo <zerm...@invalid.spam>
Date: Fri, 10 Feb 2012 21:06:22 +0000 (UTC)
Local: Fri, Feb 10 2012 4:06 pm
Subject: Re: functional code in php

On Fri, 10 Feb 2012 21:41:25 +0100, Pascal J. Bourguignon wrote:
> zermelo <zerm...@invalid.spam> writes:

>> I don't like php, but my boss wants it. So I was guessing whether
>> someone here had a remedy to alleviate the pain.

> PHP 5 even has closures, IIRC.  So you can start to apply Greenspun
> Tenth Law right now.

Searching Greenspun's law on wikipedia, I discovered the corollary of
Robert Morris, who in turn was the creator of the first computer worm and
the partner of Paul Graham of viaweb, who is an ardent advocate of Lisp:)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Margolin  
View profile  
 More options Feb 10, 6:20 pm
Newsgroups: comp.lang.lisp
From: Barry Margolin <bar...@alum.mit.edu>
Date: Fri, 10 Feb 2012 18:20:43 -0500
Local: Fri, Feb 10 2012 6:20 pm
Subject: Re: functional code in php
In article <jh3v8h$at...@dont-email.me>, zermelo <zerm...@invalid.spam>
wrote:

PHP has all of those things.

lambda = create_function
mapcar = array_map
filter = array_filter
reduce = array_reduce
funcall = Assign funcname to variable, then $variable(<args>)

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
zermelo  
View profile  
 More options Feb 11, 9:17 am
Newsgroups: comp.lang.lisp
From: zermelo <zerm...@invalid.spam>
Date: Sat, 11 Feb 2012 14:17:42 +0000 (UTC)
Local: Sat, Feb 11 2012 9:17 am
Subject: Re: functional code in php

Thanks.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
M. Strobel  
View profile  
 More options Feb 11, 11:35 am
Newsgroups: comp.lang.lisp
From: "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
Date: Sat, 11 Feb 2012 17:35:33 +0100
Local: Sat, Feb 11 2012 11:35 am
Subject: Re: functional code in php
Am 10.02.2012 21:38, schrieb zermelo:

I agree to the bastard son, but this should not keep you from writing good code.

All (small question mark here) of the necessary features are there.

You can write poems in any language.

/Str.

P.S. even with "defun"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »