Re: Euphoria 4.0.1

new topic     » goto parent     » topic index » view thread      » older message » newer message
Vinoba said...

I am only trying to point out the fallacy of saying that the simple math functions (+ - * / ) work on sequence against sequence AND sequence against a single element.

And I am afraid you are failing spectacularly. You quoted my working example. Please explain what you think was wrong with it. What do you think it should do?

Vinoba said...

It does work in an immediate mode as Matt has tried to demonstrate, but hen you have a moderately complicated business need such that you and I have to design a function for an end user, we run into a problem as we have to access each element of a sequence separately and at time the sequence may be a sequence and at times the "sequence" may only be a single value.

It's hard to understand what you really want to do here (even taking into account the cashier use case). I can't see what this has to do with sequence vs atom arithmetic.

Vinoba said...

Look at the function I wrote above and now we are going to expand it to a moderately relaistic level

500 items in a store. Each item has a separate price Some have discounts (on varying days) Whole section of items (e.g. all tiles) have one single discount as a special which will last only till Friday and then not. Customers come in and buy - sometime 5 items and sometimes 100 items and in small and large quantities. Whilst the cashier is busy, the manger comes to her and says "give him 10% discount on all lumber and 5% on all trusses", the demure old lady next in queue is waiting to buy one screwdriver only with its special discount today. What I have described is a normal store. Yes they all have nicely programmed cash machines so you and I do have to write a program for them, but supposing you were writing an application?

There's a lot here. There are interface issues. You're implying a lot of filtering (i.e., Lumber vs trusses vs other stuff). This is a lot more complex than the function that calculates prices.

Vinoba said...

Somewhere in this situation we are faced with having to operate on single values in a sequence and a function with parameters defined as (sequence a, sequence b, sequence c, sequence x, sequence y, sequence z ) does not work if we have to build a loop around each sequence items, because here, there and everywhere, now and then and tomorrow, the sequence supplied will not be sequence but a single element.

Similar problem would arise in a 80 employee office getting payroll. some have exact percentage deductions, some have special deductions, some have holiday pay etc. To accommodate all this in a FUNCTION, you have to work in a loop of a sequence of names or numbers and apply sequences of pay/hour etc. You end up with a loop and your parameter definitions (sequence a,sequence b,sequence c,sequence x,sequence y, sequence z, ) bombs.

It sounds like you want some magical language construct that knows what you want to do. I can't see any fallacy here, other than that you seem to not understand how euphoria handles sequence vs atom arithmetic. It's not some magical construct. It is either analogous to multiplying a vector by a scalar (sequence multiplied by an atom) or multiplying each element of a sequence with the respective element of another sequence (sequence multiplied by another sequence).

So, once again. Please give us an example of what you think euphoria should do, vs what it actually does. All you've done here is to present a fairly complex use case, and complain that euphoria can't read your mind, or something (sorry, but that's how it's coming across to me.)

I've given you an example that does exactly what you asked about: multiply a sequence by an atom. We can certainly discuss how to write a function using common euphorian idioms, but you're complaining about a basic operation that euphoria has always done, and you're saying it doesn't do it. Even when I've demonstrated that it does. And I also modified your function to do what I thought you were asking about.

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu