Author Topic: One up and why! (MyLine)  (Read 12553 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
One up and why! (MyLine)
« on: August 22, 2006, 09:33:00 PM »
The rules of this game are very simple; ``one up'' the previous guy. You may only adjust one (1) thing about the previous persons program. For example, if you see a spelling error you may only change that in your next post. The second rule is that your ``one up'ed'' code MUST work. And the third and final rule is that you need to give a reason why your code is ``one up'ed'' from the previous. Beyond that, the sky's the limit. You may mutate the process and procedures to suit your needs. You may gang up in teams and try and get the program to mutate into something your team wants but the ``one up'', the ``working'' and the ``why'' rules must hold true. (If you are trying to mutate the procedure you either need to find a slick way of doing it, or make up a good enough reason not to cause a stink--No ``cause I wanted to'' allowed-.)

I will start off with a very simple program that has plenty potential to grow.

You may hold general discussions in this thread with your teammates if you feel like it--no private messages for recruiting you must hold all discussions here in the open.

Official ``one up'' code must be prefixed with the tags:
One up and Why:

...So without further adieu:

One up and Why:
Initial code.
Code: [Select]
(defun MyLine ( / cntr pt1 pt2 )
  ;;
  ;; History:
  ;; 08.22.06 -- Se7en
  ;;
   (setq cntr 1
         pt1
          (getpoint
            (strcat
               "\nEnter point number "
                 (rtos cntr 2 0)
                " please: "
                )
            )
          )
   (if pt1
      (progn
        (setq cntr (1+ cntr))
        (setq pt2 (getpoint pt1
                     (strcat
                        "\nEnter point number "
                         (rtos cntr 2 0)
                        " please: "
                       )
                     )
           )
        )
      (progn
        (princ "\nYou have not entered a valid point; existing now.")
        (quit)
        )
      )
   (if pt2
      (command "_.line" pt1 pt2 "")
      (progn
        (princ "\nYou have not entered a valid point")
        (quit)
       )
     )
  )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: One up and why! (MyLine)
« Reply #1 on: August 23, 2006, 12:45:10 AM »
This variant is easier... :-)
Code: [Select]
(defun MyLine (/ pt1 pt2)
  ;;
  ;; History:
  ;; 08.23.06 -- ElpanovEvgeniy
  ;;
  (cond
    ((not (setq pt1 (getpoint "\nEnter point number 1 please: "))
     )
     (princ "\nYou have not entered a valid point 1 ")
    )
    ((not (setq pt2 (getpoint pt1 "\nEnter point number 2 please: "))
     )
     (princ "\nYou have not entered a valid point 2 ")
    )
    (t
     (entmakex
       (list
'(0 . "LINE")
(cons 10 pt1)
(cons 11 pt2)
       )
     )
    )
  )
  (princ)
)
;test:
;(MyLine)

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: One up and why! (MyLine)
« Reply #2 on: August 23, 2006, 03:24:03 AM »
One up  (princ "\nYou have not entered a valid point; exiting now.")

Why .... changed spelling mistake

Code: [Select]
(defun MyLine ( / cntr pt1 pt2 )
  ;;
  ;; History:
  ;; 08.22.06 -- Se7en
  ;;
   (setq cntr 1
         pt1
          (getpoint
            (strcat
               "\nEnter point number "
                 (rtos cntr 2 0)
                " please: "
                )
            )
          )
   (if pt1
      (progn
        (setq cntr (1+ cntr))
        (setq pt2 (getpoint pt1
                     (strcat
                        "\nEnter point number "
                         (rtos cntr 2 0)
                        " please: "
                       )
                     )
           )
        )
      (progn
        (princ "\nYou have not entered a valid point; exiting now.")
        (quit)
        )
      )
   (if pt2
      (command "_.line" pt1 pt2 "")
      (progn
        (princ "\nYou have not entered a valid point")
        (quit)
       )
     )
  )

Cool game Se7en. If this doesnt move to fast I might learn something about programming
« Last Edit: August 23, 2006, 03:25:09 AM by jonesy »
Thanks for explaining the word "many" to me, it means a lot.

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: One up and why! (MyLine)
« Reply #3 on: August 23, 2006, 06:48:07 AM »
Go Jonesy! :)
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: One up and why! (MyLine)
« Reply #4 on: August 23, 2006, 08:50:57 AM »
Code: [Select]
(DEFUN myline (/ cntr pt1 pt2)
  ;;
  ;; History:
  ;; 08.22.06 -- Se7en
  ;;
  ;; 2006.08.22 Tracey .. corrected User interface < Spelling >
  ;;
  ;; 2006.08.23 {AEST} kwb@theSwamp ..  documentation Update , reformat
  ;; 2006.08.23 {AEST} kwb@theSwamp .. add closing (princ)'s for less noise
  ;;
  (SETQ cntr 1
        pt1
         (GETPOINT
           (STRCAT "\nEnter point number "
                   (RTOS cntr 2 0)
                   " please: "
           )
         )
  )
  (IF pt1
    (PROGN (SETQ cntr (1+ cntr))
           (SETQ pt2
                  (GETPOINT
                    pt1
                    (STRCAT
                      "\nEnter point number "
                      (RTOS cntr 2 0)
                      " please: "
                    )
                  )
           )
    )
    (PROGN
      (PRINC
        "\nYou have not entered a valid point; exiting now."
      )
      (QUIT)
    )
  )
  (IF pt2
    (COMMAND "_.line" pt1 pt2 "")
    (PROGN
      (PRINC
        "\nYou have not entered a valid point"
      )
      (QUIT)
    )
  )
  (princ)
)

(princ)

[*giggle*]

One up and Why:
  ;; 2006.08.22 Tracey .. corrected User interface < Spelling >
  ;;
  ;; 2006.08.23 {AEST} kwb@theSwamp ..  documentation Update , reformat
  ;; 2006.08.23 {AEST} kwb@theSwamp .. add closing (princ)'s for less noise
« Last Edit: August 23, 2006, 08:53:56 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: One up and why! (MyLine)
« Reply #5 on: August 23, 2006, 09:02:11 AM »
Code: [Select]
(DEFUN c:myline (/ cntr pt1 pt2)
  ;;
  ;; History:
  ;; 08.22.06 -- Se7en
  ;;
  ;; 2006.08.22 Tracey .. corrected User interface < Spelling >
  ;;
  ;; 2006.08.23 {AEST} kwb@theSwamp ..  documentation Update , reformat
  ;; 2006.08.23 {AEST} kwb@theSwamp .. add closing (princ)'s for less noise
  ;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
  ;;
  (SETQ cntr 1
        pt1
         (GETPOINT
           (STRCAT "\nEnter point number "
                   (RTOS cntr 2 0)
                   " please: "
           )
         )
  )
  (IF pt1
    (PROGN (SETQ cntr (1+ cntr))
           (SETQ pt2
                  (GETPOINT
                    pt1
                    (STRCAT
                      "\nEnter point number "
                      (RTOS cntr 2 0)
                      " please: "
                    )
                  )
           )
    )
    (PROGN
      (PRINC
        "\nYou have not entered a valid point; exiting now."
      )
      (QUIT)
    )
  )
  (IF pt2
    (COMMAND "_.line" pt1 pt2 "")
    (PROGN
      (PRINC
        "\nYou have not entered a valid point"
      )
      (QUIT)
    )
  )
  (princ)
)

(princ)

One up and why
Added the C: to enable the user to type the command at the command line
Thanks for explaining the word "many" to me, it means a lot.

deegeecees

  • Guest
Re: One up and why! (MyLine)
« Reply #6 on: August 23, 2006, 10:10:42 AM »
Code: [Select]
(DEFUN c:myline (/ cntr pt1 pt2)
  ;;
  ;; History:
  ;; 08.22.06 -- Se7en
  ;;
  ;; 2006.08.22 Tracey .. corrected User interface < Spelling >
  ;;
  ;; 2006.08.23 {AEST} kwb@theSwamp ..  documentation Update , reformat
  ;; 2006.08.23 {AEST} kwb@theSwamp .. add closing (princ)'s for less noise
  ;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
  ;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
  (SETQ cntr 1
        pt1
         (GETPOINT
           (STRCAT "\nEnter point number "
                   (RTOS cntr 2 0)
                   " please: "
           )
         )
  )
  (IF pt1
    (PROGN (SETQ cntr (1+ cntr))
           (SETQ pt2
                  (GETPOINT
                    pt1
                    (STRCAT
                      "\nEnter point number "
                      (RTOS cntr 2 0)
                      " please: "
                    )
                  )
           )
    )
    (PROGN
      (PRINC
        "\nYou have not entered a valid point; exiting now."
      )
      (QUIT)
    )
  )
  (IF pt2
    (COMMAND "_.line" pt1 pt2)
    (PROGN
      (PRINC
        "\nYou have not entered a valid point"
      )
      (QUIT)
    )
  )
  (princ)
)

(princ)

One up and why
Added recursive functionality (removed exiting quotes)

JVasco

  • Guest
Re: One up and why! (MyLine)
« Reply #7 on: August 23, 2006, 10:39:14 AM »
Code: [Select]
(DEFUN c:myline (/ cntr pt1 pt2)
  ;;
  ;; History:
  ;; 08.22.06 -- Se7en
  ;;
  ;; 2006.08.22 Tracey .. corrected User interface < Spelling >
  ;;
  ;; 2006.08.23 {AEST} kwb@theSwamp ..  documentation Update , reformat
  ;; 2006.08.23 {AEST} kwb@theSwamp .. add closing (princ)'s for less noise
  ;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
  ;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
  (SETQ cntr 1
        pt1
         (GETPOINT
           (STRCAT "\nEnter point number "
                   (RTOS cntr 2 0)
                   " please: "
           )
         )
  )
  (IF pt1
    (PROGN (SETQ cntr (1+ cntr))
           (SETQ pt2
                  (GETPOINT
                    pt1
                    (STRCAT
                      "\nEnter point number "
                      (RTOS cntr 2 0)
                      " please: "
                    )
                  )
           )
    )
    (PROGN
      (PRINC
        "\nYou have not entered a valid point; exiting now."
      )
      (QUIT)
    )
  )
  (IF pt2
    (COMMAND "_.line" pt1 pt2)
    (PROGN
      (PRINC
        "\nYou have not entered a valid point"
      )
      (QUIT)
    )
  )
  (princ)
)

(princ)

One up and why
Added recursive functionality (removed exiting quotes)

I apologise, but I do not see the recursion.

lispman21

  • Guest
Re: One up and why! (MyLine)
« Reply #8 on: August 23, 2006, 10:49:35 AM »
The quotes that are highlighted are were removed.  This was the recursive functionality. (COMMAND "_.line" pt1 pt2 "")

lispman21

  • Guest
Re: One up and why! (MyLine)
« Reply #9 on: August 23, 2006, 11:15:40 AM »
One Up'ed and why

Made program more simplicit.  (did away with un-necessary progn's)


Code: [Select]
(DEFUN c:myline (/ cntr pt1 pt2)
(SETQ cntr 1
        pt1
         (GETPOINT
           (STRCAT "\nEnter point number "
                   (RTOS cntr 2 0)
                   " please: "
           )
         )
  )
  (IF pt1
    (PROGN (SETQ cntr (1+ cntr))
           (SETQ pt2
                  (GETPOINT
                    pt1
                    (STRCAT
                      "\nEnter point number "
                      (RTOS cntr 2 0)
                      " please: "
                    )
                  )
           )
    )
      (PRINC
        "\nYou have not entered a valid point; exiting now."
      )
  )
  (IF pt2
    (COMMAND "_.line" pt1 pt2"")
      (PRINC
        "\nYou have not entered a valid point; exiting now."
      )
  )
  (princ)
)

(princ)

deegeecees

  • Guest
Re: One up and why! (MyLine)
« Reply #10 on: August 23, 2006, 11:19:37 AM »
Quote
  ;;
  ;; History:
  ;; 08.22.06 -- Se7en
  ;;
  ;; 2006.08.22 Tracey .. corrected User interface < Spelling >
  ;;
  ;; 2006.08.23 {AEST} kwb@theSwamp ..  documentation Update , reformat
  ;; 2006.08.23 {AEST} kwb@theSwamp .. add closing (princ)'s for less noise
  ;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
  ;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)

A rev history would be nice. And what happened to my recursive functionality, or was that wrong?

uncoolperson

  • Guest
Re: One up and why! (MyLine)
« Reply #11 on: August 23, 2006, 11:21:55 AM »
Code: [Select]
;;
;; History:
;; 08.22.06 -- Se7en
;;
;; 2006.08.22 Tracey .. corrected User interface < Spelling >
;;
;; 2006.08.23 {AEST} kwb@theSwamp ..  documentation Update , reformat
;; 2006.08.23 {AEST} kwb@theSwamp .. add closing (princ)'s for less noise
;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
;; 2006.08.23 UnCoolPerson... added while, and associated fun. to keep DGC's idea in our lisp and not in the line command

(DEFUN c:myline (/ cntr pt1 pt2)
  (SETQ cntr 1
pt1
(GETPOINT
  (STRCAT "\nEnter point number "
  (RTOS cntr 2 0)
  " please: "
  )
)
  )
  (while pt1
    (PROGN (SETQ cntr (1+ cntr))
  (SETQ pt2
 (GETPOINT
   pt1
   (STRCAT
     "\nEnter point number "
     (RTOS cntr 2 0)
     " please: "
   )
 )
  )
    )
    (IF pt2
      (progn (COMMAND "_.line" pt1 pt2 "") (setq pt1 pt2))
      (progn (PRINC
      "\nYou have not entered a valid point; exiting now."
    )
    (setq pt1 nil)

      )
    )
    (princ)
  )
)

(princ)

Hangman

  • Swamp Rat
  • Posts: 566
Re: One up and why! (MyLine)
« Reply #12 on: August 23, 2006, 11:28:23 AM »
Code: [Select]
  ;; Program 'MyLine'
  ;;
  ;; History:
  ;; 08.22.06 -- Se7en
  ;;
  ;; 2006.08.22 Tracey .. corrected User interface < Spelling >
  ;;
  ;; 2006.08.23 {AEST} kwb@theSwamp ..  documentation Update , reformat
  ;; 2006.08.23 {AEST} kwb@theSwamp .. add closing (princ)'s for less noise
  ;; 2006.08.23 Tracey ... added the c: to allow the user to use at the command line
  ;; 2006.08.23 DGC ... added recursive functionality (removed exiting quotes)
  ;; 2006.08.23 Hangman ... replaced History & changed second point pick 'quit' to a repetitive second pick

(DEFUN c:myline (/ cntr pt1 pt2)
(SETQ cntr 1
        pt1
         (GETPOINT
           (STRCAT "\nEnter point number "
                   (RTOS cntr 2 0)
                   " please: "
           )
         )
  )
  (IF pt1
    (PROGN (SETQ cntr (1+ cntr))
           (SETQ pt2
                  (GETPOINT
                    pt1
                    (STRCAT
                      "\nEnter point number "
                      (RTOS cntr 2 0)
                      " please: "
                    )
                  )
           )
    )
    (PROGN
      (PRINC
        "\nYou have not entered a valid point; exiting now."
      )
      (QUIT)
    )
  )
  (WHILE (= pt2 nil)
    (PROGN
      (PRINC
        "\nYou have not entered a valid point"
      )
      (SETQ pt2
        (GETPOINT
          pt1
          (STRCAT
            "\nEnter point number "
            (RTOS cntr 2 0)
            " please: "
          )
        )
      )
      (COMMAND "_.line" pt1 pt2)
    )
  )
  (princ)
)

(princ)

Reinserted the History and added a 'While' statement for repetitive point 2.
« Last Edit: August 23, 2006, 11:34:12 AM by Hangman »
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hangman

  • Swamp Rat
  • Posts: 566
Re: One up and why! (MyLine)
« Reply #13 on: August 23, 2006, 11:30:29 AM »
Doht !!!
Uncool posted before I could get my too cents in. 

Uncool !!!    :-D
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

deegeecees

  • Guest
Re: One up and why! (MyLine)
« Reply #14 on: August 23, 2006, 11:39:41 AM »
I had a feeling this would be a C.F. in that respect.