TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Daniel J. Ellis on March 19, 2009, 10:03:57 AM

Title: More subroutine functions
Post by: Daniel J. Ellis on March 19, 2009, 10:03:57 AM
I currently have a (working) routine that goes:
 
Code: [Select]
(DEFUN startnum ( / )

(SETQ
start (GETINT "\nEnter first plot to renumber<1>:")
stop (GETINT "\nEnter last plot to renumber<1000>:")
step (GETINT "\nEnter amount to increase each number by (negative values decrease)<1>:")
)
(IF
(NOT start)
(SETQ start 1)
)
(IF
(NOT stop)
(SETQ stop 1000)
)
(IF
(NOT step)
(SETQ step 1)
)
)

I'm trying to simplify it to:
Code: [Select]
(DEFUN startnum ( / )
(DEFUN checkdefault ( var val / )

(IF
(NOT (VL-PRINC-TO-STRING (EVAL var)))
(SETQ var val)
)
(PRINC "\nIn CHECKDEFAULT")
(RETURNVARS 'var)
)
(SETQ
start (GETINT "\nEnter first plot to renumber<1>:")
stop (GETINT "\nEnter last plot to renumber<1000>:")
step (GETINT "\nEnter amount to increase each number by (negative values decrease)<1>:")
)



(CHECKDEFAULT 'start 1)
(CHECKDEFAULT 'stop 1000)
(CHECKDEFAULT 'step 1)

)

However, this one doesn't work.

Can anybody suggest why, or what I should be doing instead

dJE

<edit: fixed code tags>
Title: Re: More subroutine functions
Post by: gile on March 19, 2009, 12:12:08 PM
Hi,

You can use an 'OR' statment

Code: [Select]
(defun StartNum ()
  (or
    (setq start (getint "\nEnter first plot to renumber<1>:"))
    (setq start 1)
  )
  (or
    (setq stop (getint "\nEnter last plot to renumber<1000>:"))
    (setq stop 1000)
  )
  (or
    (setq step (getint"\nEnter amount to increase each number by (negative values decrease)<1>:"))
    (setq step 1)
  )
)

As the 3 expression are quite similar, you can group them in a 'MAPCAR' statment

Code: [Select]
(defun StartNum ()
  (mapcar
    '(lambda (sym val msg)
       (or (set sym (getint (strcat msg "<" (itoa val) ">:")))
   (set sym val)
       )
     )
    '(start stop step)
    '(1 1000 1)
    '("\nEnter first plot to renumber"
      "\nEnter last plot to renumber"
      "\nEnter amount to increase each number by (negative values decrease)"
     )
  )
)
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 19, 2009, 12:17:37 PM
Use COND instead of OR
(setq <var> (cond <blah> <return>))
Title: Re: More subroutine functions
Post by: CAB on March 19, 2009, 12:57:29 PM
Nice example Gile.
Title: Re: More subroutine functions
Post by: Daniel J. Ellis on March 19, 2009, 04:16:22 PM
Use COND instead of OR
(setq <var> (cond <blah> <return>))

I thought COND worked in a "pick from a list" kinda way
If item 1, do x
if item 2, do y
if item 3, do z?

What I'm doing here is getting three values, but offering a default for each.

MAPCAR looks the way to go, thanks Giles

dJE
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 19, 2009, 05:44:22 PM
No look them both up and look at the returns of each. OR returns either nil or t. ...Would you like an example instead?

Code: [Select]
(setq result
       (cond
( (getint "\nSpecify a value <7>: ") )
(7) )
      )
Title: Re: More subroutine functions
Post by: kdub on March 19, 2009, 05:55:39 PM
I'd use an OR construct similar to the one posted by gile.

...the reader just needs to glance at it to understand the functionality.


 
I currently have a (working) routine that goes:
 
Code: [Select]
(DEFUN startnum ( / )

(SETQ
start (GETINT "\nEnter first plot to renumber<1>:")
stop (GETINT "\nEnter last plot to renumber<1000>:")
step (GETINT "\nEnter amount to increase each number by (negative values decrease)<1>:")
)
(IF
(NOT start)
(SETQ start 1)
)
(IF
(NOT stop)
(SETQ stop 1000)
)
(IF
(NOT step)
(SETQ step 1)
)
)

I'm trying to simplify it to: ...

dan, how about something like :-

Code: [Select]
;; ..... < preamble >

(or  start
      (SETQ start 1)
)
(or stop
      (SETQ stop 1000)
)
(or step
      (SETQ step 1)
)





Title: Re: More subroutine functions
Post by: MP on March 19, 2009, 06:02:49 PM
Another spin ... dumbed down (i.e. no initget argument etc.) ...

Code: [Select]
(defun _GetInt ( pmt default / result )

    (setq default (if (numberp default) (fix default) 0))
   
    (if (setq result (getint (strcat pmt " <" (itoa default) ">: ")))
        result
        default
    )

)

Code: [Select]
(setq
    start (_GetInt "Enter first plot to renumber" 1)
    stop  (_GetInt "Enter last plot to renumber" 1000)
    step  (_GetInt "Enter increment value (negative to decrement)" 1)
)

Different variant illuminating what Se7en was trying to demonstrate:

Code: [Select]
(defun _GetInt ( pmt default )

    (setq default (if (numberp default) (fix default) 0))
   
    (cond
        ((getint (strcat pmt " <" (itoa default) ">: ")))
        (default)
    )

)

Subtitle: Code reuse. :)
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 19, 2009, 11:05:40 PM
I'd use an OR construct similar to the one posted by gile.

...the reader just needs to glance at it to understand the functionality.


Then you would just be perpetuating the misuse of code.

Then the reader needs to be better informed because its goofy and confusing. I think you like the use of OR because it seems like a fancy trick but if you stop and look at OR vs COND in this instance you will notice something...You know what? I'll just show you cause im sick of this crap.

OR statement (Lets remove the extra stuff and get down to the basics):
(or (setq var (getint "\nPrompt"))
   (setq var <DEFAULT>)
 )
Step thru that eval sequence.
1. run getint function
2. fill variable with result of getint function (worst case: nil).
3. if variable is nill then evaluate next process which is setting the variable to something else.
4. Return a Boolean value.

Now lets look at COND:
(setq var (cond ((getint "\nPrompt")) (<DEFAULT>) )
1. run getint function
2. if nil evaluate next (which is just a value)
3. return that value to fill the variable.

Do you see how it all plays out now?

OR can be good for running several different scenarios of process' not setting variables the statement is confusing.
Title: Re: More subroutine functions
Post by: CAB on March 20, 2009, 12:15:52 AM
In the case you presented (setq var (cond
I do prefer that method but OR has it uses and don't be so rigid with the language that
creative applications of the language are rejected. As long as the intent of the code is
not obfuscated to the average programmer I don't see the harm. But then I'm a self taught
programmer and that's where I'm coming from.

To me the OR is short hand for (if (not ) then (if (not ....
Therefore if you don't care or don't need more than the return value (T or nil) then go ahead and use it.

Just my 2 cents. :-)


<edit: fixed typo>
Title: Re: More subroutine functions
Post by: Kerry on March 20, 2009, 04:00:15 AM
I'd use an OR construct similar to the one posted by gile.

...the reader just needs to glance at it to understand the functionality.


Then you would just be perpetuating the misuse of code.

Then the reader needs to be better informed because its goofy and confusing. I think you like the use of OR because it seems like a fancy trick but if you stop and look at OR vs COND in this instance you will notice something...You know what? I'll just show you cause im sick of this crap.
< ... snip >

John, I will acknowledge that we have differing opinions an just leave it at that.

Regards
Kerry  (kdub)
Title: Re: More subroutine functions
Post by: curmudgeon on March 20, 2009, 04:10:37 AM
I think I am going to like it in this room.
Must work now - you see, Autocad 2000 does not export to gbXML, and it needs to be able to do this thing.

As far as I know it doesn't, yet.

Lots of times I look at a "finished" piece and tell myself, and others, "that's ugly, but it runs."
I get a lot of blank stares.
Title: Re: More subroutine functions
Post by: Daniel J. Ellis on March 20, 2009, 04:53:13 AM
OK,

   Gile, I think I'm going to use your mapcar(lambda) solution - it's closest to what I'd originally wanted to do.
   Se7en, I like your COND method, purely for the "purity" of the coding: it's simpler but harder to understand at first read.
   MP, is (if numberp default) checking to make sure that the default variable a number?  very "pure," but possibly superfluous for a hard-coded value?

Thanks all,
dJE
Title: Re: More subroutine functions
Post by: gile on March 20, 2009, 08:30:59 AM
Se7en,

I do agree using COND is a better way.
I only tried to help danellis simplifying his code, I apologize if my purpose drives you sick, it wasn't my intention.
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 20, 2009, 08:44:17 AM
:D No gile your fine. *lol*
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 20, 2009, 09:41:51 AM

> don't be so rigid with the language that creative applications of the language are rejected.

CAB, thats the obstacle im trying to overcome. [my] solution isnt creative, its simple logic. I would consider OR the creative use; in fact why not use IF (why use OR at all). (if (null (set var ... (set var)...?

> As long as the intent of the code is not obfuscated to the average programmer I don't see the harm.

So you DONT see "(or (set var) (set var)" as obscured instead of "(set var (condition)" That Boolean statement is masking the underlying objective: bind a variable to one of two conditions which is true.

Maybe im reading or thinking about this too much academically. When I was documenting [my] use of cond for my notes, I was following a few links and discovered this is a bona fide issue touched on by people WAY smarter then any of us. I learned that Paul Graham (I didnt know who he was before I read his Bio -- he's fricken uber smart) described this issue in a book called On-Lisp and he called it the "anaphoric-if"

,----[ anaphoric-if ]-
|
| Var is bound to the value of expr in iftrue if the value of expr satisfies the
| conditional; otherwise iffalse is evaluated.
|
|  (aif var expr
|       iftrue
|       iffalse)
|
`----

This quote was in one web page that tried to discuss his theory and I thought it was funny, and would bring some joviality to this discussion so here it is.

,----[ Quote ]-
|
|     '"...and even Stigand, the patriotic archbishop of Canterbury, found it advisable--"'
|
|     'Found what?' said the Duck.
|
|     'Found it,' the Mouse replied rather crossly: 'of course you know what "it" means.'
|
|     'I know what "it" means well enough, when I find a thing,' said the Duck: 'it's generally a frog, or a worm. The question is, what did the archbishop find?'
|
|     [Lewis Carroll, Alice's Adventures in Wonderland, Chapter III]
|
`----
Title: Re: More subroutine functions
Post by: MP on March 20, 2009, 10:10:21 AM
MP, is (if numberp default) checking to make sure that the default variable a number?  very "pure," but possibly superfluous for a hard-coded value?

Agreed. When I penned it I was thinking it would be convenient for the caller to pass nil if they didn't have a default value in mind. The upshot being that an integer (0) would still be returned. Perhaps over thought. (http://www.theswamp.org/screens/mp/facepalm.gif)
Title: Re: More subroutine functions
Post by: CAB on March 20, 2009, 10:16:54 AM
John,
As I said I prefer  "(set var (condition)" over "(or (set var) (set var)"
but i have no problem with "(or var (setq var value))" when testing for nil.

I don't care for
Code: [Select]
(setq var (cond ((null var) value)))I would use
Code: [Select]
(setq var (if (not var) value))but I prefer
Code: [Select]
(or var (setq var value))
If testing for other than nil I usually use
Code: [Select]
(if (= var constant)
  (setq var something_else)
)

That's all I have time for this morning.
See Ya.
Title: Re: More subroutine functions
Post by: MP on March 20, 2009, 10:27:30 AM
So you DONT see "(or (set var) (set var)" as obscured instead of "(set var (condition)" That Boolean statement is masking the underlying objective: bind a variable to one of two conditions which is true.

It does mask the intent, and I too am not particularly fond of it, but to each his own. Having said that, it's a challenge to post one's opinions without sounding, ummm, curt or abrasive, especially when one is passionate about programming like many of us here are. I know, because [in red faced hindsight] I've been an opinionated ass much of my online life because I've felt strong about issues but not similarly blessed with the gift of eloquently airing said opinion without pissing off / offending others or sounding arrogant, and for that I apologize and am in the debt of those that have been forgiving. To summarize, maybe take a little time to take the edges off so that one's thoughts, rather than one's attitudes are what's left in the mind of the reader.

Fully acknowledge pot calling out kettle, it's part of my therapy: can't fix what you don't acknowledge (honestly, I have been trying to mend my ways).

(http://www.theswamp.org/screens/mp/facepalm.gif) (http://www.theswamp.org/screens/mp/blush.gif) :)
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 20, 2009, 11:15:45 AM
So that quote didn't work? I thought it was hilarious myself. *

Okay. But i mean only to have discussions where `feelings' are not involved I harbor ZERO bad or ill wishes towards anyone in the coding forums. I guess i don't understand or just plain forget the whole `forum face' complex; i understand the basic psychology behind it -i.e. `big man on campus' kinda thing but i do not share that problem. I do not go to my RL best friend and tell him that i `smoked' or `got smoked' by my "online friend"; I'm almost positive that if i did he would try and punch me in the skull.  *

I will try to not post.

I am aware that i can sound gruff, but i try and warn people, and I am trying too. Ive tried several methods:
Respond with questions (this just annoying in RL so i stopped),
Responded with only code (all i got was blank stares),
...
I feel like a fricken' robot. `DANGER Will Robinson, DANGER!'  *

FWIW, here is my interpretation of a `default' get* expression for anyone who wants it.   **
Code: [Select]
(defun aif ( var expr iffalse )
  ;; anaphoric-if
  ;;
  ;; ported to AutoLisp from ?comonLisp?
  ;; I dont know the whole extents of the CL`aif' function, im only
  ;; working from one small definition.
  ;;
  ;; EX:
  ;;     (aif 'a (getint "\nEnter new value [1]: ") 1)
  ;;
  (set var (cond (expr) (iffalse))) )


Sorry,
7


*  Attempt: humor.
**   Attempt: `olive branch'.  Bad but attempted non the less.
Title: Re: More subroutine functions
Post by: MP on March 20, 2009, 11:23:52 AM
I will try to not post.

WTF? Why?

I am aware that i can sound gruff, but i try and warn people, and I am trying too.

birds of a feather ...

Ive tried several methods: Respond with questions (this just annoying in RL so i stopped),
Responded with only code (all i got was blank stares)

What is RL?

Code: [Select]
(defun aif ( var expr iffalse )
  ;; anaphoric-if
  ;;
  ;; ported to AutoLisp from ?comonLisp?
  ;; I dont know the whole extents of the CL`aif' function, im only
  ;; working from one small definition.
  ;;
  ;; EX:
  ;;     (aif 'a (getint "\nEnter new value [1]: ") 1)
  ;;
  (set var (cond (expr) (iffalse))) )

Interesting, but more cryptic than the or technique which spawned this branch of the discussion -- IMO. :)
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 20, 2009, 12:04:50 PM
Sorry should have expanded that out more. try not to post for: awhile, right away, when i feel..., when its raining. At the least I will go grab a cup 'o java first.

Real life. I thought i would spew I.R.C. Terms today. It's on my Outlook public calendar, didn't you know? *

Yeah, i feel the same. I'm not going to use it. I imagine the life of this thread will determine the existence of that abstraction.



*  Attempt: humor.


EDIT: Added `key'.
*Se7en: slaps himself with a Trout.
Title: Re: More subroutine functions
Post by: gile on March 20, 2009, 12:13:46 PM
Still about OR (and AND).

In its AutoLISP FAQ (http://faqs.cs.uu.nl/na-dir/CAD/autolisp-faq/part1.html) (subject 7), Reni Urban said :

"The following are not real bugs, that make AutoLISP crash or return
  false results. They are just bad language implementations.

  * AND and OR should return the value of the not-NIL argument
    instead of T
"

This can make sense since the AutoLISP functions using a test expression (as IF, COND, WHILE) don't need the test expression result to be strictly a Boolean (NIL or T) but Nil or anything else (as LISP is a dynamicaly typed language).
Title: Re: More subroutine functions
Post by: MP on March 20, 2009, 12:19:43 PM
@Se7en: Ok, peace, HAGWEETTYL. :P
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 20, 2009, 01:50:25 PM
Still about OR (and AND).

In its AutoLISP FAQ (http://faqs.cs.uu.nl/na-dir/CAD/autolisp-faq/part1.html) (subject 7), Reni Urban said :

"The following are not real bugs, that make AutoLISP crash or return
  false results. They are just bad language implementations.

  * AND and OR should return the value of the not-NIL argument
    instead of T
"

This can make sense since the AutoLISP functions using a test expression (as IF, COND, WHILE) don't need the test expression result to be strictly a Boolean (NIL or T) but Nil or anything else (as LISP is a dynamicaly typed language).

I believe he stated that because in the Scheme Language, that is how it treats it's Boolean expressions (I thought i remembered he stated that XLisp was a Scheme cousin or something like that in a post. But anyways...).

For example In Scheme:
Code: [Select]
(and (= 2 2) (> 2 1))                   =>  #t
(and (= 2 2) (< 2 1))                   =>  #f
(and 1 2 'c '(f g))                     =>  (f g)
(and) 

(or (= 2 2) (> 2 1))                    =>  #t
(or (= 2 2) (< 2 1))                    =>  #t
(or #f #f #f)                           =>  #f
(or (memq 'b '(a b c)) (/ 3 0))         =>  (b c)
Therefore in Scheme: (set var (or <condition> <condition> ... would be legal.

But i could be wrong.
Title: Re: More subroutine functions
Post by: CAB on March 20, 2009, 02:28:18 PM
Here is my olive branch but watch out for the thorns. :-D

Sorry, bad joke.

How about an attempt at our own OR and AND that does return a value?

Problem is that you need to use a list because of the undetermined number of arguments.
Try this out.
Code: [Select]
(defun _or (lst / result)
  (vl-some (function (lambda(x) (setq result (eval x)))) lst)
  result
)

(defun _and (lst / result)
  (if (vl-every (function (lambda(x) (setq result (eval x)))) lst)
    result
  )
)


(defun c:test()
  (print (_or '((= 2 3)(> 2 5)(+ 2 3))))
  (print (_and '((= 2 3)(> 2 5)(+ 2 3))))
  (print (_and '((= 2 2)(> 8 5)(+ 2 3))))
  (princ)
)
Title: Re: More subroutine functions
Post by: gile on March 20, 2009, 03:42:46 PM
Quote
How about an attempt at our own OR and AND that does return a value?

Code: [Select]
(defun _or (lst / r)
  (if lst
    (if (setq r (eval (car lst)))
      r
      (_or (cdr lst))
    )
  )
)


(defun _and (lst)
  (if (cdr lst)
    (if (eval (car lst))
      (_and (cdr lst))
    )
    (eval (car lst))
  )
)

OR with COND

Code: [Select]
(defun _or (lst)
  (eval (cons 'cond (mapcar 'list lst)))
)
Title: Re: More subroutine functions
Post by: Daniel J. Ellis on March 20, 2009, 03:44:13 PM
MP, is (if numberp default) checking to make sure that the default variable a number?  very "pure," but possibly superfluous for a hard-coded value?

Agreed. When I penned it I was thinking it would be convenient for the caller to pass nil if they didn't have a default value in mind. The upshot being that an integer (0) would still be returned. Perhaps over thought. (http://www.theswamp.org/screens/mp/facepalm.gif)

Gotya.  I can see how it could have its uses, but think it would overkill in this situation (the whole purpose is to set a default, after all)  It's a trick I'll try to remember for future use though.

dJE
Title: Re: More subroutine functions
Post by: Kerry on March 20, 2009, 08:53:04 PM
I've ordered a T Shirt ..
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 20, 2009, 08:54:53 PM
Ok, that was funny.
Title: Re: More subroutine functions
Post by: Mark on March 24, 2009, 08:29:58 AM
Not sure if I would consider myself even an 'average programmer' but a lot of what I see here would be 'obfuscated'. :)

Also, since we're talking about someone else reading the code, I didn't see anyone mention comments.

My simple approach might be something like this.
Code: [Select]
;;
;; setup default values
;;
(if (not (setq start (getint "\nEnter first plot to renumber<1>:")))
  ;; if user responds with <enter> set default
  (setq start 1)
  )

(if (not (setq stop (getint "\nEnter last plot to renumber<1000>:")))
  ;; if user responds with <enter> set default
  (setq stop 1000)
  )

(if (not (setq stepping (getint "\nEnter amount to increase each number by (negative values decrease)<1>:")))
  ;; if user responds with <enter> set default
  (setq stepping 1)
  )
Title: Re: More subroutine functions
Post by: CAB on March 24, 2009, 09:14:48 AM
That method "Reads Well" even without the comments.  :-)
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 10:10:03 AM
That method "Reads Well" even without the comments.  :-)

self documenting one might say :)
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 24, 2009, 10:21:49 AM
I'm going to kick the back your chairs!
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 10:23:36 AM
wut
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 24, 2009, 10:29:28 AM
Post #15 i said to do just exactly that but all i got was Kerry ordering a t-shirt. Now that someone you guys actually like comes along...I'm gonna kick your chairs.
Title: Re: More subroutine functions
Post by: Mark on March 24, 2009, 10:31:07 AM
I'm going to kick the back your chairs!
:lol:
Title: Re: More subroutine functions
Post by: Mark on March 24, 2009, 10:33:37 AM
Post #15 i said to do just exactly that but all i got was Kerry ordering a t-shirt. Now that someone you guys actually like comes along...I'm gonna kick your chairs.

Ah, so you did. Missed that one.

CAB, thats the obstacle im trying to overcome. [my] solution isnt creative, its simple logic. I would consider OR the creative use; in fact why not use IF (why use OR at all). (if (null (set var ... (set var)...?
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 24, 2009, 10:35:09 AM
I'm going to kick the back your chairs!
:lol:

Oh sure, keep playing with fire. ...I actually know what you look like!
Title: Re: More subroutine functions
Post by: CAB on March 24, 2009, 10:40:08 AM
OK, we got John by the tail. Just gotta be quick or he'll bite ya. :lmao:
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 10:42:12 AM
Just keep swinging him, you'll be fine.  :-D
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 24, 2009, 10:43:58 AM
You guys are just lucky this computer is connected with only CAT 5 cable, cause if i had a wire for fists...
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 10:45:38 AM
<Al Borland> I don't think so Tim. </Al Borland>
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 24, 2009, 10:52:30 AM
*click* *snicker* Ive already started my virus. *sneer*
((0 1 1 1 0 1 0 0) (0 1 1 0 1 0 0 0) (0 1 1 0 0 1 0 1) (0 1 0 1 0 0 1 1) (0 1 1 1 0 1 1 1) (0 1 1 0 0 0 0 1) (0 1 1 0 1 1 0 1) (0 1 1 1 0 0 0 0) (0 0 1 0 1 1 1 0) (0 1 1 0 1 1 1 1) (0 1 1 1 0 0 1 0) (0 1 1 0 0 1 1 1) (0 0 1 0 0 0 0 0) (0 1 1 0 1 0 0 1) (0 1 1 1 0 0 1 1) (0 0 1 0 0 0 0 0) (0 1 1 1 0 1 0 0) (0 1 1 0 1 0 0 0) (0 1 1 0 0 1 0 1) (0 0 1 0 0 0 0 0) (0 1 1 1 0 0 0 0) (0 1 1 0 1 1 0 0) (0 1 1 0 0 0 0 1) (0 1 1 0 0 0 1 1) (0 1 1 0 0 1 0 1) (0 0 1 0 0 0 0 0) (0 1 1 1 0 1 0 0) (0 1 1 0 1 1 1 1) (0 0 1 0 0 0 0 0) (0 1 1 0 0 1 1 1) (0 1 1 0 0 1 0 1) (0 1 1 1 0 1 0 0) (0 0 1 0 0 0 0 0) (0 1 1 0 1 0 0 0) (0 1 1 0 0 1 0 1) (0 1 1 0 1 1 0 0) (0 1 1 1 0 0 0 0) (0 0 1 0 1 1 1 0))
Title: Re: More subroutine functions
Post by: Mark on March 24, 2009, 10:56:15 AM
You guys are just lucky this computer is connected with only CAT 5 cable, cause if i had a wire for fists...
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 11:07:27 AM
*click* *snicker* Ive already started my virus. *sneer*
((0 1 1 1 0 1 0 0) (0 1 1 0 1 0 0 0) (0 1 1 0 0 1 0 1) (0 1 0 1 0 0 1 1) (0 1 1 1 0 1 1 1) (0 1 1 0 0 0 0 1) (0 1 1 0 1 1 0 1) (0 1 1 1 0 0 0 0) (0 0 1 0 1 1 1 0) (0 1 1 0 1 1 1 1) (0 1 1 1 0 0 1 0) (0 1 1 0 0 1 1 1) (0 0 1 0 0 0 0 0) (0 1 1 0 1 0 0 1) (0 1 1 1 0 0 1 1) (0 0 1 0 0 0 0 0) (0 1 1 1 0 1 0 0) (0 1 1 0 1 0 0 0) (0 1 1 0 0 1 0 1) (0 0 1 0 0 0 0 0) (0 1 1 1 0 0 0 0) (0 1 1 0 1 1 0 0) (0 1 1 0 0 0 0 1) (0 1 1 0 0 0 1 1) (0 1 1 0 0 1 0 1) (0 0 1 0 0 0 0 0) (0 1 1 1 0 1 0 0) (0 1 1 0 1 1 1 1) (0 0 1 0 0 0 0 0) (0 1 1 0 0 1 1 1) (0 1 1 0 0 1 0 1) (0 1 1 1 0 1 0 0) (0 0 1 0 0 0 0 0) (0 1 1 0 1 0 0 0) (0 1 1 0 0 1 0 1) (0 1 1 0 1 1 0 0) (0 1 1 1 0 0 0 0) (0 0 1 0 1 1 1 0))

It sure is. :)
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 24, 2009, 11:13:21 AM
It sure is. :)
*gack* We've been compromised! Quick start the `XOR-5000'.
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 11:20:47 AM
*gack* We've been compromised! Quick start the `XOR-5000'.

lol

Some python ...

Code: [Select]
#!/usr/bin/env python

# Python 3.x :)

binList=[[0, 1, 1, 1, 0, 1, 0, 0],
         [0, 1, 1, 0, 1, 0, 0, 0],
         [0, 1, 1, 0, 0, 1, 0, 1],
         [0, 1, 0, 1, 0, 0, 1, 1],
         [0, 1, 1, 1, 0, 1, 1, 1],
         [0, 1, 1, 0, 0, 0, 0, 1],
         [0, 1, 1, 0, 1, 1, 0, 1],
         [0, 1, 1, 1, 0, 0, 0, 0],
         [0, 0, 1, 0, 1, 1, 1, 0],
         [0, 1, 1, 0, 1, 1, 1, 1],
         [0, 1, 1, 1, 0, 0, 1, 0],
         [0, 1, 1, 0, 0, 1, 1, 1],
         [0, 0, 1, 0, 0, 0, 0, 0],
         [0, 1, 1, 0, 1, 0, 0, 1],
         [0, 1, 1, 1, 0, 0, 1, 1],
         [0, 0, 1, 0, 0, 0, 0, 0],
         [0, 1, 1, 1, 0, 1, 0, 0],
         [0, 1, 1, 0, 1, 0, 0, 0],
         [0, 1, 1, 0, 0, 1, 0, 1],
         [0, 0, 1, 0, 0, 0, 0, 0],
         [0, 1, 1, 1, 0, 0, 0, 0],
         [0, 1, 1, 0, 1, 1, 0, 0],
         [0, 1, 1, 0, 0, 0, 0, 1],
         [0, 1, 1, 0, 0, 0, 1, 1],
         [0, 1, 1, 0, 0, 1, 0, 1],
         [0, 0, 1, 0, 0, 0, 0, 0],
         [0, 1, 1, 1, 0, 1, 0, 0],
         [0, 1, 1, 0, 1, 1, 1, 1],
         [0, 0, 1, 0, 0, 0, 0, 0],
         [0, 1, 1, 0, 0, 1, 1, 1],
         [0, 1, 1, 0, 0, 1, 0, 1],
         [0, 1, 1, 1, 0, 1, 0, 0],
         [0, 0, 1, 0, 0, 0, 0, 0],
         [0, 1, 1, 0, 1, 0, 0, 0],
         [0, 1, 1, 0, 0, 1, 0, 1],
         [0, 1, 1, 0, 1, 1, 0, 0],
         [0, 1, 1, 1, 0, 0, 0, 0],
         [0, 0, 1, 0, 1, 1, 1, 0]]
 
def binListToInt(b):
    power=result=0
    for i in range(7,-1,-1):
        result+=2**power if b[i] else 0
        power+=1
    return result

for x in [chr(x) for x in [binListToInt(x) for x in binList]]:
    print(x,end="")

>>> theSwamp.org is the place to get help.

PYFTW

:D
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 24, 2009, 11:31:52 AM
(http://www.theswamp.org/lilly_pond/index.php?dir=john/&file=marvin_the_martian.jpg)
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 12:38:39 PM
Where's the kaboom!!
























There's supposed to be an earth shattering kaboom!!
Title: Re: More subroutine functions
Post by: ronjonp on March 24, 2009, 12:45:02 PM
Where's the kaboom!!
























There's supposed to be an earth shattering kaboom!!

 :-D
"Capture that creature and return my illudium pu36 explosive space modulator!"

*picky picky  :-P
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 12:54:55 PM
"Capture that creature and return my elunium pu36 explosive space modulator!"

All these years I thought it was "illudium pu 36 explosive space modulator", am I wrong !!??

Oh the shame. (http://www.theswamp.org/screens/mp/blush.gif)
Title: Re: More subroutine functions
Post by: John Kaul (Se7en) on March 24, 2009, 12:58:16 PM
I thought it was "Illudium" but i cant spell my own name so...
Title: Re: More subroutine functions
Post by: T.Willey on March 24, 2009, 01:03:28 PM
Quote
[Marvin notices that his space modulator is missing and he discovers Bugs running off with it]
Marvin the Martian: The illudium Q-36 explosive space modulator! That creature has stolen the space modulator!

[ http://www.imdb.com/title/tt0051701/quotes ]
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 01:10:04 PM
Tim FTW!
Title: Re: More subroutine functions
Post by: T.Willey on March 24, 2009, 01:30:31 PM
Tim FTW!

Somethings are easier to search for than others.  :wink:
Title: Re: More subroutine functions
Post by: gskelly on March 24, 2009, 01:40:35 PM
You folks are quite a hoot! Got me laughing out loud sitting in a room by myself!!!
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 01:46:18 PM
You folks are quite a hoot! Got me laughing out loud sitting in a padded room by myself!!!

 :loco:
Title: Re: More subroutine functions
Post by: gskelly on March 24, 2009, 01:48:39 PM
Your not the first to tell me that :-)
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 01:49:06 PM
Ahhh, the voices are back?
Title: Re: More subroutine functions
Post by: gskelly on March 24, 2009, 01:50:25 PM
Singing like angels!
Title: Re: More subroutine functions
Post by: MP on March 24, 2009, 01:56:21 PM
Lucky you, mine have babel fish problems.