Author Topic: Name the process :: Game 1  (Read 8056 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Name the process :: Game 1
« on: May 10, 2006, 08:45:08 AM »
The object of this game is to name the process you want done on this function. The first one to post, gets to name the overall process preformed. Then we have to build our procedures based on those instructions. For instance; here is a sample game played out.


*** POST 1

Given the list: (0 1 2 3 4 5 6 7 8 9)
I want to ___________.

*** POST 2

Return the list with he last item removed.

*** POST 3

(defun pop-last (l)
  (reverse (cdr (reverse l))) )


(Obviously, thats a very simple example, but im not going to build a complex example for something that im not entirely sure is going to 'fly'.) I think this game could be alot of fun because of the lack of direction (so to speak) You are free to do as you want without restraints.

So...

Given the list: (0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9)
I want to ___________.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

uncoolperson

  • Guest
Re: Name the process :: Game 1
« Reply #1 on: May 10, 2006, 10:11:33 AM »
dent it up real good?



list unique?
(create a list of lists of unique values from a list of not so unique values)



JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Name the process :: Game 1
« Reply #2 on: May 10, 2006, 11:49:13 AM »
What?!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

uncoolperson

  • Guest
Re: Name the process :: Game 1
« Reply #3 on: May 10, 2006, 12:38:24 PM »
i did it once... and i forgot what i did to make it pretty...



turn a list like;
(1 2 3 4 5 4 4 2 1 3 6 7 4 6 9 6 5 1 3)

into
(( 1 2 3 4 5 6 7 9 ) ( 1 2 3 4 5 6 ) ( 1 3 4 6 ) ( 4 ))

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Name the process :: Game 1
« Reply #4 on: May 11, 2006, 08:55:44 AM »
Code: [Select]
(defun for-theswamp (lst)
  (if lst
    ((lambda (x)
       (cons (vl-sort (car x) '<) (for-theswamp (cadr x)))
     ) ;_  lambda
      (for-theswamp-1 (cdr lst) (list (car lst)) nil)
    )
  ) ;_  if
) ;_  defun
(defun for-theswamp-1 (lst a1 a2)
  (if lst
    (if (member (car lst) a1)
      (for-theswamp-1 (cdr lst) a1 (cons (car lst) a2))
      (for-theswamp-1 (cdr lst) (cons (car lst) a1) a2)
    ) ;_  if
    (list a1 a2)
  ) ;_  if
) ;_  defun


(for-theswamp  '(1 2 3 4 5 4 4 2 1 3 6 7 4 6 9 6 5 1 3))
;; => '((1 2 3 4 5 6 7 9) (1 2 3 4 5 6) (1 3 4 6) (4))

uncoolperson

  • Guest
Re: Name the process :: Game 1
« Reply #5 on: May 11, 2006, 10:22:05 AM »
i thought i had killed this

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Name the process :: Game 1
« Reply #6 on: May 11, 2006, 10:36:35 AM »
i thought i had killed this
I have not understood you...
I have written this program today.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Name the process :: Game 1
« Reply #7 on: May 11, 2006, 11:18:41 AM »
AS I understand uncoolperson comment, I think he was saying that he killed the thread due to the lack of activity.
I just think people are too busy to participate, anyway that's my excuse.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Name the process :: Game 1
« Reply #8 on: May 11, 2006, 12:54:50 PM »
Thank for explanations Alan :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Name the process :: Game 1
« Reply #9 on: May 11, 2006, 01:06:07 PM »
You are welcome.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Name the process :: Game 1
« Reply #10 on: May 11, 2006, 01:33:28 PM »
You are welcome.

If, my course...

Sort the list which is not using SETQ, VL-*
Code: [Select]
(setq lst '(7 3 4 6 9 6 7 2 5 3 2 3 6 4 6 3 1)
      f   (function <)
)
(defun sort (lst f)
  ?????
)
  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Name the process :: Game 1
« Reply #11 on: May 11, 2006, 01:44:50 PM »
Code: [Select]
(defun sort (lst)
  (dos_sortlist lst)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Name the process :: Game 1
« Reply #12 on: May 11, 2006, 01:47:29 PM »
Shortly, but for me does not work... :-(

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Name the process :: Game 1
« Reply #13 on: May 11, 2006, 01:49:30 PM »
Code: [Select]
(defun sort (lst)
  (dos_sortlist lst)
)
For this program, it is necessary dos_lib?

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Name the process :: Game 1
« Reply #14 on: May 12, 2006, 01:42:52 PM »
Probably, I have not understood, game rules...
Where I can see or explain me.
Beforehand thank!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Name the process :: Game 1
« Reply #15 on: May 12, 2006, 02:46:22 PM »
ElpanovEvgeniy
I think you got it.
You started with a hard one. I tried for about 15 minutes but no easy solution.
Perhaps you can post your solution.

I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Name the process :: Game 1
« Reply #16 on: May 12, 2006, 02:57:23 PM »
ElpanovEvgeniy
I think you got it.
You started with a hard one. I tried for about 15 minutes but no easy solution.
Perhaps you can post your solution.

Version 1
Code: [Select]
(defun rec-min (lst mi f)
  ;(rec-min (cdr lst) (car lst) f)
  (cond
    ((not lst) mi)
    (((eval f) (car lst) mi)
     (rec-min (cdr lst) (car lst) f)
    )
    (t (rec-min (cdr lst) mi f))
  ) ;_  cond
) ;_  defun
(defun rec-remove-singl (i lst)
  ;(rec-remove-singl (cadr lst) lst)
  (if lst
    (if (equal i (car lst))
      (cdr lst)
      (cons (car lst) (rec-remove-singl i (cdr lst)))
    ) ;_  if
  ) ;_  if
) ;_  defun
(defun rec-sort-min (lst f)
  ;(rec-sort-min lst)
  (if lst
    ((lambda (x)
       (cons
         x
         (rec-sort-min
           (rec-remove-singl
             x
             lst
           )
           f
         )
       )
     ) ;_  lambda
      (rec-min (cdr lst) (car lst) f)
    )
  ) ;_  if
) ;_  defun

  ; Check:
(setq lst '(7 3 4 6 9 6 7 2 5 3 2 3 6 4 6 3 1)
      f   (function <)
) ;_  setq
(rec-sort-min lst f)
Version 2
Code: [Select]
(defun rec-min-max (lst mi ma f)
  (cond
    ((not lst) (list mi ma))
    (((eval f) (car lst) mi)
     (rec-min-max (cdr lst) (car lst) ma f)
    )
    (((eval f) ma (car lst))
     (rec-min-max (cdr lst) mi (car lst) f)
    )
    (t (rec-min-max (cdr lst) mi ma f))
  ) ;_  cond
) ;_  defun
(defun rec-remove-singl (i lst)
  (if lst
    (if (equal i (car lst))
      (cdr lst)
      (cons (car lst) (rec-remove-singl i (cdr lst)))
    ) ;_  if
  ) ;_  if
) ;_  defun
(defun rec-sort-min-max (lst f)
  (cond
    ((not lst) nil)
    ((not(cdr lst)) lst)
    (t
     ((lambda (x)
        (cons
          (car x)
          (append
            (rec-sort-min-max
              (rec-remove-singl
                (car x)
                (rec-remove-singl
                  (cadr x)
                  lst
                ) ;_  rec-remove-singl
              ) ;_  rec-remove-singl
              f
            ) ;_  rec-sort-lists
            (cdr x)
          ) ;_  append
        ) ;_  cons
      ) ;_  lambda
       (rec-min-max (cdr lst) (car lst) (car lst) f)
     )
    )
  ) ;_  cond
) ;_  defun

  ; Check:
(setq lst '(7 3 4 6 9 6 7 2 5 3 2 3 6 4 6 3 1)
      f   (function <)
) ;_  setq
(rec-sort-min-max lst f)

Version 3
Code: [Select]
(defun rec-quicksort-2 (lst lst1 lst2 test f)
  (cond
    ((not lst)
      (list lst1 (list test) lst2)
    )
    (((eval f) (car lst) test)
     (rec-quicksort-2 (cdr lst) (cons (car lst) lst1) lst2 test f)
    )
    (t (rec-quicksort-2 (cdr lst) lst1 (cons (car lst) lst2) test f))
  ) ;_  cond
) ;_  defun

(defun rec-quicksort-1 (lst f)
  (cond
    ((not lst) nil)
    ((not (car lst)) (rec-quicksort-1 (cdr lst) f))
    ((not (cdar lst))
     (cons (caar lst) (rec-quicksort-1 (cdr lst) f))
    )
    ((not (cddar lst))
     (if (apply f (car lst))
       (cons (caar lst) (cons (cadar lst) (rec-quicksort-1 (cdr lst) f)))
       (cons (cadar lst) (cons (caar lst) (rec-quicksort-1 (cdr lst) f)))
     ) ;_  if
    )
    (t
     ((lambda (x)
        (rec-quicksort-1 (cons (car x) (cons (cadr x) (cons (caddr x) (cdr lst)))) f)
      ) ;_  lambda
       (rec-quicksort-2 (cdar lst) nil nil (caar lst) f)
     )
    )
  ) ;_  cond
) ;_  defun

(defun rec-quicksort (lst f)
  (rec-quicksort-1 (list lst) f)
) ;_  defun

  ; Check:
(setq lst '(7 3 4 6 9 6 7 2 5 3 2 3 6 4 6 3 1)
      f   (function <)
) ;_  setq
(rec-quicksort lst f)


ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
« Last Edit: May 12, 2006, 03:29:36 PM by ElpanovEvgeniy »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Name the process :: Game 1
« Reply #18 on: May 12, 2006, 05:26:34 PM »
No wonder I was having trouble figuring it out. :)
Thanks for the link, I'll do some reading. Just need more time....
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.