in reply to Re: Re: $a++ allowed by $a-- is not ! why?
in thread $a++ allowed by $a-- is not ! why?
Modern algebra would say that although ++ is one-to-one, it is not onto.why? it is a mapping from N to N (if i understand you correctly).
Given a function F from set S to set T, F is said to be one-to-one if F(s) is equal to a unique t in T for all s in S, and F is said to be onto if for all t in T there exists exactly one s in S such that F(s)=t. In our case both S and T are the same set, the set of all finite numbers and alphanumeric strings. (I believe (Inf)++ is also defined, but that can be considered a special case.)
++ as it is defined in Perl is one-to-one because each possible number or alphanumeric string has a unique successor, but it is not onto because it is not true that each number or alphanumeric string has a unique predecessor.
why do you think -- is a permutation?
Because, its domain and range are the same set (specifically, the set of all finite numbers; again, (Inf)-- is also defined but can be considered a special case, a polymorphism if you will) and it is both one-to-one and onto.
You can also consider ++ to be a permutation over the set of all finite numbers, if you consider the string magic to be a polymorphism, but ++ is definitely not a permutation over the set of alphanumeric strings, because it is not onto.
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: $a++ allowed by $a-- is not ! why?
by tilly (Archbishop) on Sep 01, 2003 at 21:58 UTC | |
by jonadab (Parson) on Sep 02, 2003 at 01:35 UTC | |
by kabel (Chaplain) on Sep 02, 2003 at 08:48 UTC | |
by tilly (Archbishop) on Sep 03, 2003 at 04:57 UTC |