all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Lists composed of equal number and kind of elements
@ 2015-07-27  7:11 Andreas Röhler
  2015-07-27 13:17 ` Drew Adams
  2015-07-27 23:31 ` Emanuel Berg
  0 siblings, 2 replies; 27+ messages in thread
From: Andreas Röhler @ 2015-07-27  7:11 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

is there a handy way to check if two lists --results of (window-list) 
precisely-- are equal WRT to the kind and number elements?

The order of elements should be ignored.

Thanks,

Andreas



^ permalink raw reply	[flat|nested] 27+ messages in thread

* RE: Lists composed of equal number and kind of elements
  2015-07-27  7:11 Lists composed of equal number and kind of elements Andreas Röhler
@ 2015-07-27 13:17 ` Drew Adams
  2015-07-27 15:35   ` Andreas Röhler
  2015-07-27 23:31 ` Emanuel Berg
  1 sibling, 1 reply; 27+ messages in thread
From: Drew Adams @ 2015-07-27 13:17 UTC (permalink / raw)
  To: Andreas Röhler, help-gnu-emacs

> is there a handy way to check if two lists --results of (window-list)
> precisely-- are equal WRT to the kind and number elements?
> The order of elements should be ignored.

Try `cl-set-exclusive-or', from cl-seq.el.

,----
| cl-set-exclusive-or is an autoloaded Lisp function in `cl-seq.el'.
| 
| (cl-set-exclusive-or LIST1 LIST2 [KEYWORD VALUE]...)
| 
| Combine LIST1 and LIST2 using a set-exclusive-or operation.
| The resulting list contains all items appearing in exactly one of LIST1, LIST2.
| This is a non-destructive function; it makes a copy of the data if necessary
| to avoid corrupting the original LIST1 and LIST2.
| 
| Keywords supported:  :test :test-not :key
`----



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-27 13:17 ` Drew Adams
@ 2015-07-27 15:35   ` Andreas Röhler
  0 siblings, 0 replies; 27+ messages in thread
From: Andreas Röhler @ 2015-07-27 15:35 UTC (permalink / raw)
  To: help-gnu-emacs

Am 27.07.2015 um 15:17 schrieb Drew Adams:
>> is there a handy way to check if two lists --results of (window-list)
>> precisely-- are equal WRT to the kind and number elements?
>> The order of elements should be ignored.
> Try `cl-set-exclusive-or', from cl-seq.el.
>
> ,----
> | cl-set-exclusive-or is an autoloaded Lisp function in `cl-seq.el'.
> |
> | (cl-set-exclusive-or LIST1 LIST2 [KEYWORD VALUE]...)
> |
> | Combine LIST1 and LIST2 using a set-exclusive-or operation.
> | The resulting list contains all items appearing in exactly one of LIST1, LIST2.
> | This is a non-destructive function; it makes a copy of the data if necessary
> | to avoid corrupting the original LIST1 and LIST2.
> |
> | Keywords supported:  :test :test-not :key
> `----

Thanks!



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-27  7:11 Lists composed of equal number and kind of elements Andreas Röhler
  2015-07-27 13:17 ` Drew Adams
@ 2015-07-27 23:31 ` Emanuel Berg
  2015-07-27 23:52   ` John Mastro
  2015-07-28  1:07   ` Drew Adams
  1 sibling, 2 replies; 27+ messages in thread
From: Emanuel Berg @ 2015-07-27 23:31 UTC (permalink / raw)
  To: help-gnu-emacs

Andreas Röhler <andreas.roehler@easy-emacs.de> writes:

> is there a handy way to check if two lists --results
> of (window-list) precisely-- are equal WRT to the
> kind and number elements?
>
> The order of elements should be ignored.

A list where you don't care about the order of the
elements is a *set*. (In the abstract sense, a set
doesn't have an order.) This is from the world of
set theory, and relational algebra; and it is all
easily illustrated with Venn diagrams which people
might remember from throwing rocks as kids and then
drawing circles to indicate territorial advances.

If the order do count in a list, the interpretation is
there is size and direction but no position - i.e.,
we have a *vector*. Not surprisingly Emacs has that
implemented in yet another way (because Emacs exists
in the domain which I have fondly nicknamed
"reality"). This however is in the world of
linear algebra. The interesting thing about this field
of mathematics, is that it is actually useful!
GPS works with several satellites sending information
as vectors and then you have it put together in
a matrix where any incorrect reading will be
canceled out by the "redundant" correct information!

Anyway, to answer your question, try this:

    (defun set-equal (list-1 list-2)
      (and (null (cl-set-exclusive-or list-1 list-2))
           (= (length list-1)
              (length list-2)) ))

Note: Depending what is deemed faster and/or more
likely to tell the correct state, the order of the
`and' arguments could be reversed...

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-27 23:31 ` Emanuel Berg
@ 2015-07-27 23:52   ` John Mastro
  2015-07-27 23:55     ` Fwd: " John Mastro
                       ` (2 more replies)
  2015-07-28  1:07   ` Drew Adams
  1 sibling, 3 replies; 27+ messages in thread
From: John Mastro @ 2015-07-27 23:52 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

> Anyway, to answer your question, try this:
>
>     (defun set-equal (list-1 list-2)
>       (and (null (cl-set-exclusive-or list-1 list-2))
>            (= (length list-1)
>               (length list-2)) ))
>
> Note: Depending what is deemed faster and/or more
> likely to tell the correct state, the order of the
> `and' arguments could be reversed...

If `cl-set-exclusive-or' returns nil, aren't the two lists guaranteed to
have the same length?

-- 
john



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Fwd: Lists composed of equal number and kind of elements
  2015-07-27 23:52   ` John Mastro
@ 2015-07-27 23:55     ` John Mastro
  2015-07-27 23:56     ` Emanuel Berg
       [not found]     ` <mailman.7498.1438041516.904.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 27+ messages in thread
From: John Mastro @ 2015-07-27 23:55 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

>> Anyway, to answer your question, try this:
>>
>>     (defun set-equal (list-1 list-2)
>>       (and (null (cl-set-exclusive-or list-1 list-2))
>>            (= (length list-1)
>>               (length list-2)) ))
>>
>> Note: Depending what is deemed faster and/or more
>> likely to tell the correct state, the order of the
>> `and' arguments could be reversed...
>
>If `cl-set-exclusive-or' returns nil, aren't the two lists guaranteed to
>have the same length?

Doh! I just realized my error:

    (cl-set-exclusive-or '(a a b) '(a b)) ;=> nil

-- 
john


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-27 23:52   ` John Mastro
  2015-07-27 23:55     ` Fwd: " John Mastro
@ 2015-07-27 23:56     ` Emanuel Berg
       [not found]     ` <mailman.7498.1438041516.904.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 27+ messages in thread
From: Emanuel Berg @ 2015-07-27 23:56 UTC (permalink / raw)
  To: help-gnu-emacs

John Mastro <john.b.mastro@gmail.com> writes:

>> Anyway, to answer your question, try this: (defun
>> set-equal (list-1 list-2) (and (null
>> (cl-set-exclusive-or list-1 list-2)) (= (length
>> list-1) (length list-2)) )) Note: Depending what is
>> deemed faster and/or more likely to tell the correct
>> state, the order of the `and' arguments could be
>> reversed...
>
> If `cl-set-exclusive-or' returns nil, aren't the two
> lists guaranteed to have the same length?

No: (cl-set-exclusive-or '(1) '(1 1)) ; nil

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 27+ messages in thread

* RE: Lists composed of equal number and kind of elements
  2015-07-27 23:31 ` Emanuel Berg
  2015-07-27 23:52   ` John Mastro
@ 2015-07-28  1:07   ` Drew Adams
  2015-07-28 21:10     ` Emanuel Berg
       [not found]     ` <mailman.7570.1438117959.904.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 27+ messages in thread
From: Drew Adams @ 2015-07-28  1:07 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

>     (defun set-equal (list-1 list-2)
>       (and (null (cl-set-exclusive-or list-1 list-2))
>            (= (length list-1)
>               (length list-2)) ))

All you need to test is (cl-set-exclusive-or list-1 list-2).

(a a a b b), (b b a), and (b a) all represent the same set.

IOW, neither order nor duplication matters.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
       [not found]     ` <mailman.7498.1438041516.904.help-gnu-emacs@gnu.org>
@ 2015-07-28 14:34       ` Barry Margolin
  2015-07-28 21:11         ` Emanuel Berg
       [not found]         ` <mailman.7571.1438118111.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 27+ messages in thread
From: Barry Margolin @ 2015-07-28 14:34 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.7498.1438041516.904.help-gnu-emacs@gnu.org>,
 Emanuel Berg <embe8573@student.uu.se> wrote:

> John Mastro <john.b.mastro@gmail.com> writes:
> 
> >> Anyway, to answer your question, try this: (defun
> >> set-equal (list-1 list-2) (and (null
> >> (cl-set-exclusive-or list-1 list-2)) (= (length
> >> list-1) (length list-2)) )) Note: Depending what is
> >> deemed faster and/or more likely to tell the correct
> >> state, the order of the `and' arguments could be
> >> reversed...
> >
> > If `cl-set-exclusive-or' returns nil, aren't the two
> > lists guaranteed to have the same length?
> 
> No: (cl-set-exclusive-or '(1) '(1 1)) ; nil

It can only happen if there are duplicates in one of the lists. The OP 
said that this is specifically for the result of (window-list), which 
can't return duplicates. So he doesn't need a fully general solution.

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


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
       [not found] <mailman.7450.1437981102.904.help-gnu-emacs@gnu.org>
@ 2015-07-28 17:10 ` Pascal J. Bourguignon
  0 siblings, 0 replies; 27+ messages in thread
From: Pascal J. Bourguignon @ 2015-07-28 17:10 UTC (permalink / raw)
  To: help-gnu-emacs

Andreas Röhler <andreas.roehler@easy-emacs.de> writes:

> is there a handy way to check if two lists --results of (window-list)
> precisely-- are equal WRT to the kind and number elements?
>
> The order of elements should be ignored.

(require 'cl)
(setf lexical-binding t)

(defun* set-equal (a b &key (test (function eql)))
  (and (subsetp a b :test test)
       (subsetp b a :test test)))

(defun equivalence-classes (set equalf)
  (loop with classes = (quote ())
     for item in set
     for class = (car (member* item classes
                               :test equalf  :key (function second)))
     do (if class
            (push item (cdr class))
            (push (list :class item) classes))
     finally (return (mapcar (function cdr) classes))))

(defun* equal-wrt-kind-and-number-of-elements
    (list1 list2 &key (kind 'type-of) (test 'equal))
  (flet ((reduce-to-classes (list)
           (mapcar (lambda (class) (list (first class) (length class)))
                   (equivalence-classes (mapcar kind list) test))))
    (and (= (length list1) (length list2))
         (set-equal (reduce-to-classes list1)
                    (reduce-to-classes list2)
                    :test (lambda (c1 c2)
                            (and (= (second c1) (second c2))
                                 (funcall test (first c1) (first c2))))))))



(equal-wrt-kind-and-number-of-elements '("a" 1 2 b c d)
                                       '(x 3 y 4 z "zz"))
t

(equal-wrt-kind-and-number-of-elements '("a" 1 2 b c d)
                                       '(x 3 y 4 z xx))
nil

(equal-wrt-kind-and-number-of-elements '("a" 1 2 b c d)
                                       '(x 3 y 4 z "a" "b"))
nil



-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-28  1:07   ` Drew Adams
@ 2015-07-28 21:10     ` Emanuel Berg
       [not found]     ` <mailman.7570.1438117959.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 27+ messages in thread
From: Emanuel Berg @ 2015-07-28 21:10 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams <drew.adams@oracle.com> writes:

> All you need to test is (cl-set-exclusive-or list-1
> list-2).
>
> (a a a b b), (b b a), and (b a) all represent the
> same set.
>
> IOW, neither order nor duplication matters.

The OP didn't say anything about sets - I said that.
The OP said he wanted equality with respect to the
same items being there (order not important) and the
lists having the same length.

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-28 14:34       ` Barry Margolin
@ 2015-07-28 21:11         ` Emanuel Berg
       [not found]         ` <mailman.7571.1438118111.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 27+ messages in thread
From: Emanuel Berg @ 2015-07-28 21:11 UTC (permalink / raw)
  To: help-gnu-emacs

Barry Margolin <barmar@alum.mit.edu> writes:

> It can only happen if there are duplicates in one of
> the lists. The OP said that this is specifically for
> the result of (window-list), which can't return
> duplicates. So he doesn't need a fully
> general solution.

OK, good point.

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
       [not found]     ` <mailman.7570.1438117959.904.help-gnu-emacs@gnu.org>
@ 2015-07-28 21:34       ` Pascal J. Bourguignon
  2015-07-28 21:37         ` Emanuel Berg
  0 siblings, 1 reply; 27+ messages in thread
From: Pascal J. Bourguignon @ 2015-07-28 21:34 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> Drew Adams <drew.adams@oracle.com> writes:
>
>> All you need to test is (cl-set-exclusive-or list-1
>> list-2).
>>
>> (a a a b b), (b b a), and (b a) all represent the
>> same set.
>>
>> IOW, neither order nor duplication matters.
>
> The OP didn't say anything about sets - I said that.
> The OP said he wanted equality with respect to the
> same items being there (order not important) and the
> lists having the same length.

No, didn't say same items.  
Said same number and same kind.
What is the kind of an item? Didn't say.

Therefore my solution is parameterised by a kind function.
Since we don't know what the kind of an item is, it is also
parameterised by an equality test for those kinds.


-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
       [not found]         ` <mailman.7571.1438118111.904.help-gnu-emacs@gnu.org>
@ 2015-07-28 21:37           ` Pascal J. Bourguignon
  2015-07-29  2:16             ` Emanuel Berg
       [not found]             ` <mailman.7584.1438136310.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 27+ messages in thread
From: Pascal J. Bourguignon @ 2015-07-28 21:37 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> Barry Margolin <barmar@alum.mit.edu> writes:
>
>> It can only happen if there are duplicates in one of
>> the lists. The OP said that this is specifically for
>> the result of (window-list), which can't return
>> duplicates. So he doesn't need a fully
>> general solution.
>
> OK, good point.

Not really.  

I mean, ok, always implementing the most specific solution to customers'
request is a good way to ensure job security.

But if your purpose is to change the world really, and not just giving
lip service to Silicon Valley mantras,  then you will implement the most
general solution so you don't have to do anything else when the customer
or another comes with a variant of their problem, and so eventually we
can leave programs and robots work for us.


-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-28 21:34       ` Pascal J. Bourguignon
@ 2015-07-28 21:37         ` Emanuel Berg
  0 siblings, 0 replies; 27+ messages in thread
From: Emanuel Berg @ 2015-07-28 21:37 UTC (permalink / raw)
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com>
writes:

> No, didn't say same items. Said same number and same
> kind. What is the kind of an item? Didn't say.
>
> Therefore my solution is parameterised by a kind
> function. Since we don't know what the kind of an
> item is, it is also parameterised by an equality
> test for those kinds.

Did anyone say just how creative one has to be to get
a valid excuse to write even more Lisp?

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-28 21:37           ` Pascal J. Bourguignon
@ 2015-07-29  2:16             ` Emanuel Berg
  2015-07-29  7:21               ` Marcin Borkowski
       [not found]             ` <mailman.7584.1438136310.904.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 27+ messages in thread
From: Emanuel Berg @ 2015-07-29  2:16 UTC (permalink / raw)
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com>
writes:

>>> So he doesn't need a fully general solution.
>> OK, good point.
>
> Not really.
>
> I mean, ok, always implementing the most specific
> solution to customers' request is a good way to
> ensure job security.
>
> But if your purpose is to change the world really,
> and not just giving lip service to Silicon Valley
> mantras, then you will implement the most general
> solution so you don't have to do anything else when
> the customer or another comes with a variant of
> their problem, and so eventually we can leave
> programs and robots work for us.

The purpose is always to change the world (or some
part of it, which is the same). But that robot thing
I don't want ever to happen because then what will *I*
do all days (and nights)? That would be
super-depressing!

But in general I agree the most general solution is
the best, and if specific interfaces are needed, those
are super-easy to add (especially in Lisp).

In this case tho it isn't exactly clear what the
most general solution is. Is it set equality where
duplicates don't matter, or is it set equality plus
list-length equality? Pairing both with `and' seems
the right thing to do - then the only problem is what
to call the function...

While the OP mentioned (window-list) it is conceivable
he will find reason to reuse this in the future - it
is even likely if he is a good programmer. Then he can
either use the most general solution, or provide a new
interface, if needed, but only if *now* he chooses
a general solution. Otherwise he wouldn't have advanced
anything by doing this now, save for experience, but
that isn't specific to doing the specific thing!

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
       [not found]             ` <mailman.7584.1438136310.904.help-gnu-emacs@gnu.org>
@ 2015-07-29  4:32               ` Pascal J. Bourguignon
  2015-07-29  5:31                 ` Rusi
  2015-07-29 22:45                 ` Emanuel Berg
  0 siblings, 2 replies; 27+ messages in thread
From: Pascal J. Bourguignon @ 2015-07-29  4:32 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> "Pascal J. Bourguignon" <pjb@informatimago.com>
> writes:
>
>>>> So he doesn't need a fully general solution.
>>> OK, good point.
>>
>> Not really.
>>
>> I mean, ok, always implementing the most specific
>> solution to customers' request is a good way to
>> ensure job security.
>>
>> But if your purpose is to change the world really,
>> and not just giving lip service to Silicon Valley
>> mantras, then you will implement the most general
>> solution so you don't have to do anything else when
>> the customer or another comes with a variant of
>> their problem, and so eventually we can leave
>> programs and robots work for us.
>
> The purpose is always to change the world (or some
> part of it, which is the same). But that robot thing
> I don't want ever to happen because then what will *I*
> do all days (and nights)? That would be
> super-depressing!

You will write the programs you want in the language you want, instead
of having to write the programs your boss wants you to write, in the
language he wants you to write programs in.


-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-29  4:32               ` Pascal J. Bourguignon
@ 2015-07-29  5:31                 ` Rusi
  2015-07-29  5:43                   ` Pascal J. Bourguignon
  2015-07-29 10:06                   ` Andreas Röhler
  2015-07-29 22:45                 ` Emanuel Berg
  1 sibling, 2 replies; 27+ messages in thread
From: Rusi @ 2015-07-29  5:31 UTC (permalink / raw)
  To: help-gnu-emacs

On Wednesday, July 29, 2015 at 10:03:02 AM UTC+5:30, Pascal J. Bourguignon wrote:
> Emanuel Berg  writes:
> 
> > "Pascal J. Bourguignon" 
> > writes:
> >
> >>>> So he doesn't need a fully general solution.
> >>> OK, good point.
> >>
> >> Not really.
> >>
> >> I mean, ok, always implementing the most specific
> >> solution to customers' request is a good way to
> >> ensure job security.
> >>
> >> But if your purpose is to change the world really,
> >> and not just giving lip service to Silicon Valley
> >> mantras, then you will implement the most general
> >> solution so you don't have to do anything else when
> >> the customer or another comes with a variant of
> >> their problem, and so eventually we can leave
> >> programs and robots work for us.
> >
> > The purpose is always to change the world (or some
> > part of it, which is the same). But that robot thing
> > I don't want ever to happen because then what will *I*
> > do all days (and nights)? That would be
> > super-depressing!
> 
> You will write the programs you want in the language you want, instead
> of having to write the programs your boss wants you to write, in the
> language he wants you to write programs in.

Heh Pascal!
Is there any emacs function that also gives salaries?


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-29  5:31                 ` Rusi
@ 2015-07-29  5:43                   ` Pascal J. Bourguignon
  2015-07-29  6:20                     ` Rusi
  2015-07-29  7:18                     ` Marcin Borkowski
  2015-07-29 10:06                   ` Andreas Röhler
  1 sibling, 2 replies; 27+ messages in thread
From: Pascal J. Bourguignon @ 2015-07-29  5:43 UTC (permalink / raw)
  To: help-gnu-emacs

Rusi <rustompmody@gmail.com> writes:

> On Wednesday, July 29, 2015 at 10:03:02 AM UTC+5:30, Pascal J. Bourguignon wrote:
>> Emanuel Berg  writes:
>> 
>> > "Pascal J. Bourguignon" 
>> > writes:
>> >
>> >>>> So he doesn't need a fully general solution.
>> >>> OK, good point.
>> >>
>> >> Not really.
>> >>
>> >> I mean, ok, always implementing the most specific
>> >> solution to customers' request is a good way to
>> >> ensure job security.
>> >>
>> >> But if your purpose is to change the world really,
>> >> and not just giving lip service to Silicon Valley
>> >> mantras, then you will implement the most general
>> >> solution so you don't have to do anything else when
>> >> the customer or another comes with a variant of
>> >> their problem, and so eventually we can leave
>> >> programs and robots work for us.
>> >
>> > The purpose is always to change the world (or some
>> > part of it, which is the same). But that robot thing
>> > I don't want ever to happen because then what will *I*
>> > do all days (and nights)? That would be
>> > super-depressing!
>> 
>> You will write the programs you want in the language you want, instead
>> of having to write the programs your boss wants you to write, in the
>> language he wants you to write programs in.
>
> Heh Pascal!
> Is there any emacs function that also gives salaries?

You don't need a salary once you have robots doing our jobs.

If you need something, you go to the Amazon.com web site, order the
stuff you want, and the robots build or grow it and deliver it to your
place with googlecars.  Robots don't need  salary, so you don't have to
pay them to work for you.

Now you may ask what about the transition period when not everything is
robotisized yet?  It's why we need universal revenue.  So we may stop
working for capitalistic corporations, and instead work on the resource
based robotic production and distribution system.

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-29  5:43                   ` Pascal J. Bourguignon
@ 2015-07-29  6:20                     ` Rusi
  2015-07-29 15:45                       ` Pascal J. Bourguignon
  2015-07-29  7:18                     ` Marcin Borkowski
  1 sibling, 1 reply; 27+ messages in thread
From: Rusi @ 2015-07-29  6:20 UTC (permalink / raw)
  To: help-gnu-emacs

On Wednesday, July 29, 2015 at 11:13:48 AM UTC+5:30, Pascal J. Bourguignon wrote:
> Rusi  writes:
> 
> > On Wednesday, July 29, 2015 at 10:03:02 AM UTC+5:30, Pascal J. Bourguignon wrote:
> >> Emanuel Berg  writes:
> >> 
> >> > "Pascal J. Bourguignon" 
> >> > writes:
> >> >
> >> >>>> So he doesn't need a fully general solution.
> >> >>> OK, good point.
> >> >>
> >> >> Not really.
> >> >>
> >> >> I mean, ok, always implementing the most specific
> >> >> solution to customers' request is a good way to
> >> >> ensure job security.
> >> >>
> >> >> But if your purpose is to change the world really,
> >> >> and not just giving lip service to Silicon Valley
> >> >> mantras, then you will implement the most general
> >> >> solution so you don't have to do anything else when
> >> >> the customer or another comes with a variant of
> >> >> their problem, and so eventually we can leave
> >> >> programs and robots work for us.
> >> >
> >> > The purpose is always to change the world (or some
> >> > part of it, which is the same). But that robot thing
> >> > I don't want ever to happen because then what will *I*
> >> > do all days (and nights)? That would be
> >> > super-depressing!
> >> 
> >> You will write the programs you want in the language you want, instead
> >> of having to write the programs your boss wants you to write, in the
> >> language he wants you to write programs in.
> >
> > Heh Pascal!
> > Is there any emacs function that also gives salaries?
> 
> You don't need a salary once you have robots doing our jobs.
> 
> If you need something, you go to the Amazon.com web site, order the
> stuff you want, and the robots build or grow it and deliver it to your
> place with googlecars.  Robots don't need  salary, so you don't have to
> pay them to work for you.
> 
> Now you may ask what about the transition period when not everything is
> robotisized yet?  It's why we need universal revenue.  So we may stop
> working for capitalistic corporations, and instead work on the resource
> based robotic production and distribution system.

Awww... You've spoilt my day Pascal!
I was sure you would have an elisp magic spell to pay salaries


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-29  5:43                   ` Pascal J. Bourguignon
  2015-07-29  6:20                     ` Rusi
@ 2015-07-29  7:18                     ` Marcin Borkowski
  1 sibling, 0 replies; 27+ messages in thread
From: Marcin Borkowski @ 2015-07-29  7:18 UTC (permalink / raw)
  To: help-gnu-emacs


On 2015-07-29, at 07:43, Pascal J. Bourguignon <pjb@informatimago.com> wrote:

> Rusi <rustompmody@gmail.com> writes:
>
>> Heh Pascal!
>> Is there any emacs function that also gives salaries?

I'm pretty sure you could hack the `butterfly' function to do that.

> You don't need a salary once you have robots doing our jobs.

Not measured in dollars, probably.  But in joules.

BTW, this no-money, post-scarcity utopia is not going to work anyway.

(Note to Emanuel: I'm with you on this robots & work issue.)

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-29  2:16             ` Emanuel Berg
@ 2015-07-29  7:21               ` Marcin Borkowski
  2015-07-29 22:57                 ` Emanuel Berg
  2015-07-29 23:04                 ` Emanuel Berg
  0 siblings, 2 replies; 27+ messages in thread
From: Marcin Borkowski @ 2015-07-29  7:21 UTC (permalink / raw)
  To: help-gnu-emacs


On 2015-07-29, at 04:16, Emanuel Berg <embe8573@student.uu.se> wrote:

> "Pascal J. Bourguignon" <pjb@informatimago.com>
> writes:
>
>>>> So he doesn't need a fully general solution.
>>> OK, good point.
>>
>> Not really.
>>
>> I mean, ok, always implementing the most specific
>> solution to customers' request is a good way to
>> ensure job security.

:-)

>> But if your purpose is to change the world really,
>> and not just giving lip service to Silicon Valley
>> mantras, then you will implement the most general
>> solution so you don't have to do anything else when
>> the customer or another comes with a variant of
>> their problem, and so eventually we can leave
>> programs and robots work for us.
>
> The purpose is always to change the world (or some
> part of it, which is the same). But that robot thing
> I don't want ever to happen because then what will *I*
> do all days (and nights)? That would be
> super-depressing!

Yes.

> But in general I agree the most general solution is
> the best, and if specific interfaces are needed, those
> are super-easy to add (especially in Lisp).

No.  Most general might be too expensive (in terms of computer resources
or programmer resources).

> In this case tho it isn't exactly clear what the
> most general solution is. Is it set equality where
> duplicates don't matter, or is it set equality plus
> list-length equality? Pairing both with `and' seems
> the right thing to do - then the only problem is what
> to call the function...

multiset-equal?

https://en.wikipedia.org/wiki/Multiset

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-29  5:31                 ` Rusi
  2015-07-29  5:43                   ` Pascal J. Bourguignon
@ 2015-07-29 10:06                   ` Andreas Röhler
  1 sibling, 0 replies; 27+ messages in thread
From: Andreas Röhler @ 2015-07-29 10:06 UTC (permalink / raw)
  To: help-gnu-emacs


Am 29.07.2015 um 07:31 schrieb Rusi:
> On Wednesday, July 29, 2015 at 10:03:02 AM UTC+5:30, Pascal J. Bourguignon wrote:
>> Emanuel Berg  writes:
>>
>>> "Pascal J. Bourguignon"
>>> writes:
>>>
>>>>>> So he doesn't need a fully general solution.
>>>>> OK, good point.
>>>> Not really.
>>>>
>>>> I mean, ok, always implementing the most specific
>>>> solution to customers' request is a good way to
>>>> ensure job security.
>>>>
>>>> But if your purpose is to change the world really,
>>>> and not just giving lip service to Silicon Valley
>>>> mantras, then you will implement the most general
>>>> solution so you don't have to do anything else when
>>>> the customer or another comes with a variant of
>>>> their problem, and so eventually we can leave
>>>> programs and robots work for us.
>>> The purpose is always to change the world (or some
>>> part of it, which is the same). But that robot thing
>>> I don't want ever to happen because then what will *I*
>>> do all days (and nights)? That would be
>>> super-depressing!
>> You will write the programs you want in the language you want, instead
>> of having to write the programs your boss wants you to write, in the
>> language he wants you to write programs in.
> Heh Pascal!
> Is there any emacs function that also gives salaries?

Then all checking for duplicates should be removed from these instance.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-29  6:20                     ` Rusi
@ 2015-07-29 15:45                       ` Pascal J. Bourguignon
  0 siblings, 0 replies; 27+ messages in thread
From: Pascal J. Bourguignon @ 2015-07-29 15:45 UTC (permalink / raw)
  To: help-gnu-emacs

Rusi <rustompmody@gmail.com> writes:

> Awww... You've spoilt my day Pascal!
> I was sure you would have an elisp magic spell to pay salaries

There's always M-x butterfly RET 

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-29  4:32               ` Pascal J. Bourguignon
  2015-07-29  5:31                 ` Rusi
@ 2015-07-29 22:45                 ` Emanuel Berg
  1 sibling, 0 replies; 27+ messages in thread
From: Emanuel Berg @ 2015-07-29 22:45 UTC (permalink / raw)
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com>
writes:

> You will write the programs you want in the language
> you want, instead of having to write the programs
> your boss wants you to write, in the language he
> wants you to write programs in.

I'm convinced - long live the
robo-algorithmic revolution!

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-29  7:21               ` Marcin Borkowski
@ 2015-07-29 22:57                 ` Emanuel Berg
  2015-07-29 23:04                 ` Emanuel Berg
  1 sibling, 0 replies; 27+ messages in thread
From: Emanuel Berg @ 2015-07-29 22:57 UTC (permalink / raw)
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:

>> But in general I agree the most general solution is
>> the best, and if specific interfaces are needed,
>> those are super-easy to add (especially in Lisp).
>
> No. Most general might be too expensive (in terms of
> computer resources or programmer resources).

What I mean is, for example, `+' is the most general
function for addition. So it is the best one, and if
you want to add addition to your game which doesn't
have addition, `+' is what you should aim for.

Later, if you find all day long you do (+ something 6)
you can easily write an interface to `+' that
does this.

Especially wise if that recurring 6 isn't just equal
to the other 6s by coincidence but represents the same
data item, e.g. the six sides of a hex nut.

Then, if the robo-politbureau decides the robotic
vanguard will use eighth sided nuts for their sword
arms, you don't have to search and replace 6s which in
the bargain might catch one 6 that *isn't* the sides
of a nut - instead, you just change the variable
value. Where is that defined? In the interface to `+',
the one that does what you want!

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Lists composed of equal number and kind of elements
  2015-07-29  7:21               ` Marcin Borkowski
  2015-07-29 22:57                 ` Emanuel Berg
@ 2015-07-29 23:04                 ` Emanuel Berg
  1 sibling, 0 replies; 27+ messages in thread
From: Emanuel Berg @ 2015-07-29 23:04 UTC (permalink / raw)
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:

> multiset-equal?
>
> https://en.wikipedia.org/wiki/Multiset

OK, so there is a word for it.

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2015-07-29 23:04 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-27  7:11 Lists composed of equal number and kind of elements Andreas Röhler
2015-07-27 13:17 ` Drew Adams
2015-07-27 15:35   ` Andreas Röhler
2015-07-27 23:31 ` Emanuel Berg
2015-07-27 23:52   ` John Mastro
2015-07-27 23:55     ` Fwd: " John Mastro
2015-07-27 23:56     ` Emanuel Berg
     [not found]     ` <mailman.7498.1438041516.904.help-gnu-emacs@gnu.org>
2015-07-28 14:34       ` Barry Margolin
2015-07-28 21:11         ` Emanuel Berg
     [not found]         ` <mailman.7571.1438118111.904.help-gnu-emacs@gnu.org>
2015-07-28 21:37           ` Pascal J. Bourguignon
2015-07-29  2:16             ` Emanuel Berg
2015-07-29  7:21               ` Marcin Borkowski
2015-07-29 22:57                 ` Emanuel Berg
2015-07-29 23:04                 ` Emanuel Berg
     [not found]             ` <mailman.7584.1438136310.904.help-gnu-emacs@gnu.org>
2015-07-29  4:32               ` Pascal J. Bourguignon
2015-07-29  5:31                 ` Rusi
2015-07-29  5:43                   ` Pascal J. Bourguignon
2015-07-29  6:20                     ` Rusi
2015-07-29 15:45                       ` Pascal J. Bourguignon
2015-07-29  7:18                     ` Marcin Borkowski
2015-07-29 10:06                   ` Andreas Röhler
2015-07-29 22:45                 ` Emanuel Berg
2015-07-28  1:07   ` Drew Adams
2015-07-28 21:10     ` Emanuel Berg
     [not found]     ` <mailman.7570.1438117959.904.help-gnu-emacs@gnu.org>
2015-07-28 21:34       ` Pascal J. Bourguignon
2015-07-28 21:37         ` Emanuel Berg
     [not found] <mailman.7450.1437981102.904.help-gnu-emacs@gnu.org>
2015-07-28 17:10 ` Pascal J. Bourguignon

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.