Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

SICP

Name: Anonymous 2008-12-23 14:30

I'm now readin SICP.Its not a bad book at all.
Its notation however sucks:
(+ (* 3 (+ (* 2 4) (+ 3 5))) (+ (- 10 7) 6))
There is no way i could see which empty)( places contain which operators without reading entire string piece by piece.
This wouldn't work with larger strings.

Name: Anonymous 2008-12-23 14:34

I'm now readin SICP.Its not a bad book at all.
Its notation however sucks:
3*(2*4 + 3 + 5) + 10 - 7 + 6
There is no way i could see which empty)( places contain which operators without reading entire string piece by piece.
This wouldn't work with larger strings.

Name: Anonymous 2008-12-23 14:37

>>2
Why they don't use this format? Its far easier to read.

Name: Anonymous 2008-12-23 14:40

>>3
In what way? It requires mentally running through some arbitrary order of operations to find out what it does, and it also duplicates operators.

Name: Anonymous 2008-12-23 14:43

compare readibility:
(define (abs x)
  (cond ((> x 0) x)
        ((= x 0) 0)
        ((< x 0) (- x))))

function abs(x){
if(x>0){return x}
if(x=0){return 0}
if(x<0){return -x}
}

Name: Anonymous 2008-12-23 14:46

MORE OPTIMIZED:
function abs(x){if(x<0){return -x}; return x}

Name: Anonymous 2008-12-23 14:49

>>4
It shows the operators.
Your version hides the operators.
When i debug code i want to see operators NOW.
I don't want to evaluate the ()(()()()( aids.

Name: Anonymous 2008-12-23 14:55

>>5
What if I told you that |0| = -0?

Name: Anonymous 2008-12-23 14:56

>>6
built-in Math.abs() is.. 1.5 times slower.

Name: Anonymous 2008-12-23 14:58

>>8
Blame SICP authors.Its their own code.

Name: Anonymous 2008-12-23 15:02

(+ (* 3 (+ (* 2 4) (+ 3 5))) (+ (- 10 7) 6))
((((2 * 4) + (3 + 5)) * 3) + ((10 - 7) + 6))

Name: Anonymous 2008-12-23 15:02

>>6
MORE MORE OPTIMIZED:
int
abs(int i)
{
  switch(i) {
    ...
    case -1:
      return 1;
    case  0:
      return 0;
    case  1:
      return 1;
    ...
  }
}

Name: Anonymous 2008-12-23 15:06

>>12
MORE MORE MORE OPTIMIZED:
int abses[] = { 0, 1, ... };

int
abs(int i)
{
  if(i < 0)
    return (abses[-i]);
  else
    return (abses[i]);
}

Name: Anonymous 2008-12-23 15:09

This is how we would do it in haskell

abs _ = error "wrong argument!"

Name: Anonymous 2008-12-23 15:15

>>14
Wat?

Name: Anonymous 2008-12-23 15:16

>>14
That is not Haskell. I don't see any Nomads.

Name: Anonymous 2008-12-23 15:18

Sorry, I meant

abs _ = error "type error"

Name: Anonymous 2008-12-23 15:23

>>13
for extra speed use this version:
function absvalue(x,sign){
if(sign=='-'){x='-'+x}
if(sign=='+'){x='+'+x}
x=parseInt(x);
if(x>0){var result="Positive"}
if(x=0){var result="Zero"}
if(x<0){var result="Negative"}
switch(result){
case "Positive":
return x;break;
case "Zero":
return x;break;
case "Negative";
return negative(x);break;
}

function negative(x){
var y=0-x;
return y
}

}

Name: Anonymous 2008-12-23 16:45

>>7
It... hides the operators? (- 1 (+ 1 1 1 1 1 1 1 1 1 1 1 1 1)) What is hidden here? Contrast with 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 1 + 1 + 1 + 1 What's hidden here?

Name: Anonymous 2008-12-23 16:48

OP has a valid point.  There should be some way to "pretty print" the expression automatically so the tree structure is obvious.  How can I do that in DrScheme (or any other scheme that doesn't suck)?

Name: Anonymous 2008-12-23 16:53

>>19
(- 1 (+ 1 1 1 1 1 1 1 11 1 1 1 1 1)(-1 1 1 1 1 1 1 1 1 1 11 1 1))

Name: Anonymous 2008-12-23 16:57

>>21
What does the function "-1" do?

Name: Anonymous 2008-12-23 16:57

>>19
OPTIMIZED:
dec(sum([1,1,1,1,1,1,1,1,1,1,1,1,1]))
 function sum(x){var s=0;for(i in x){s+=x[i]};return s}
function dec(x){return x--}

Name: Anonymous 2008-12-23 17:06

>>22
Whoops.I wasn't  aware Scheme was so context-sensitive.
Its should decrement by 1.

Name: Anonymous 2008-12-23 22:30

>>20
You can always write it yourself.

Name: Anonymous 2008-12-23 23:24

inline assembly is the answer! Spread the word!

Name: Anonymous 2008-12-24 1:10

>>22
Pedantic git

Name: Anonymous 2008-12-24 2:53

>>6
FURTHER OPTIMIZATION:
function abs(x){return (x > 0) ? x : -x}

Name: Anonymous 2008-12-24 2:54

>>28
*bitmasks are even faster,but they are unreliable.

Name: Anonymous 2008-12-24 3:35

>>27
There was little else to reply to in that content-free post.

Name: Anonymous 2008-12-24 3:36

>>30
the -1 has no relevance,the subject was how hard is to read infix vs standard

Name: Anonymous 2008-12-24 3:39

>>31
Infix is standard.

Name: Anonymous 2008-12-24 3:41

>>32
In your little circle of academia maybe.

Name: Anonymous 2008-12-24 3:44

>>33
Infix is stuff like 1 + 2 right? Have I been trolled?

Name: Anonymous 2008-12-24 3:53

>>34
Have I been trolled?
Quite so, old friend.

Name: Anonymous 2008-12-24 4:01

no one outside of computer science uses prefix notation. everyone uses infix or postfix notation in the real world.

Name: Anonymous 2008-12-24 4:10

Educationally, RPN calculators have the advantage that the user must understand the expression being calculated: it is not possible to simply copy the expression from paper into the machine and read off the answer without understanding. One must calculate from the middle of the expression, which makes life easier but only if the user understands what they are doing.

Name: Anonymous 2008-12-24 4:31

Educationally, prefix notation calculators have the advantage that the user must understand the expression being calculated: it is not possible to simply copy the expression from paper into the machine and read off the answer without understanding. One must start in the middle of the expression, reverse half of it, interleave the backwards into the forward half, and add parentheses in all the right places.

Name: Anonymous 2008-12-24 4:42

parsing prefix and infix notation requires slow as fuck recursive algorithms due to their complicated syntax. postfix notation is superior.

Name: Anonymous 2008-12-24 4:50

I want to see LISPfags using prefix calculators IRL and talking about how natural and efficient it is.

Name: Anonymous 2008-12-24 5:12

>>41
Each calculator would have a metal imprint of SICP over a Jerry Sussman portrait on its back.

Name: Anonymous 2008-12-24 5:16

Name: Anonymous 2008-12-24 5:30

>>33
One time some asshole gave me this same bullshit about prefix versus infix, claiming that children in civilized first-world nations (i.e., not the US) are taught to do arithmetic in prefix notation. He couldn't tell me where. He would also interrupt my and other people's conversations whenever somebody referred to something in imperial units by quickly converting to the metric equivalent and "correcting" us. He also kept switching whatever lab computer he happened to be using to Dvorak layout and sneered at others for being so inefficient as to use QWERTY. This was years ago before Asperger's diagnosis was all the rage. Others probably think you're a troll, but now I suspect you are that guy. Fuck you Jacob you stupid cunt.

Name: Anonymous 2008-12-24 5:42

>>40
I don't see why it wouldn't be. Each operator would introduce an opening paren before itself, and rather than the enter key a normal calculator has, there would be a close paren. When all parens were closed, the expression would be evaluated.

Name: Anonymous 2008-12-24 5:46

>>12
bad style, use:

int
abs(int i)
{
  switch(i) {
    ...
    case -1:
      return 1;
      break;
    case  0:
      return 0;
      break;
    case  1:
      return 1;
      break;
    ...
    default:
      break;
  }
}

Name: Anonymous 2008-12-24 5:47

>>43
AGREED

PREFIX -> WIENERS

METRIC -> WIENERS

DVORAK -> WIENERS

Name: Anonymous 2008-12-24 5:48

>>45
GO BACK TO TROLL LAND

Name: Anonymous 2008-12-24 5:51

>>45
almost ENTERPRISE QUALITY

int
abs(int i)
{
  switch(i) {
    ...
    case -1:
      return 1;
      break;
    case  0:
      return 0;
      break;
    case  1:
      return 1;
      break;
    ...
    default:
        {
        throw new System.ArgumentException("Parameter invalid");
    }
  }
}

Name: Anonymous 2008-12-24 5:59

>>44
What would you push in between numbers? Space?

1 + 2 + 3 + 4 + 5 =: 10 keypresses
1 enter 2 + 3 + 4 + 5 +: 10 keypresses
+ 1 space 2 space 3 space 4 space 5 closeparen: 11 keypresses

Name: Anonymous 2008-12-24 6:02

>>49
I suggest a new addition to the standard 105 key keyboard: The GRUNNER button

Name: Anonymous 2008-12-24 6:03

>>49
Think of how many keys you spent arguing about this.

Name: Anonymous 2008-12-24 6:10

Name: Anonymous 2008-12-24 6:16

>>49
Hmm, the critical flaw.

Name: Anonymous 2008-12-24 6:21

>>52
free

For Macs? Unpossible!

Name: Anonymous 2008-12-24 6:23

>>54
Port it to windows.Its should be easy(python is cross-platform)

Name: Anonymous 2008-12-24 6:43

Prefix is a prefix (polish notation) command line calculator written in python. Prefix 1.5.1 fixes issues with the - character being used as the subtraction operator. prefix often gets confused and thinks it's an operator. The supported subtraction character is now the _ (underscore) character though if the - character was working before it 1.5.1 will be backwards compatible with 1.5.

Name: Anonymous 2008-12-24 7:28


          ∧_∧   / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
          ( ´∀`) < COOL FREE PREFIX CALCULATORS http://ln-s.net/2bOK
        /    |    \
       /       .|      ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
       / "⌒ヽ |.イ |
   __ |   .ノ | || |__
  .    ノく__つ∪∪   \
   _((_________\
    ̄ ̄ヽつ ̄ ̄ ̄ ̄ ̄ ̄ | | ̄

Name: Anonymous 2008-12-24 7:54

>>41
OPTIMIZED:
Each calculator would have a metal imprint of SICP over a Julie Sussman portrait on its back.

Name: Anonymous 2008-12-24 7:59

>>51
Think of how many keys you spent arguing about this.

Name: Anonymous 2008-12-24 8:00

>>57
ARMPIT SCHEME

Name: Anonymous 2008-12-24 8:02

>>60
inb4 someone forks it to Neckbeard Scheme.

Name: Anonymous 2008-12-24 8:08

>>58
FURTHER OPTIMIZED:
Each calculator would have a metal imprint of Julie Sussman portrait on its back.

Name: Anonymous 2008-12-24 8:22

>>62
FURTHER FURTHER OPTIMIZED:
Each calculator would be Julie Sussman.

Name: Anonymous 2008-12-24 8:34

>>63
Reduces functionality.
>>62
PROPER OPTIMIZATION:
Each calculator would have a metal imprint of naked Julie Sussman on its back.

Name: Anonymous 2008-12-24 11:03

I'm invented a new lisp dialect!!!!!!!
It's called wicky scheme especialy disegened as a lightweight DSL for mediawiki on web 2.0 -- I blogged about how I fixed the problem of scheme which was unspecified order by specifying evaluation order! I am so great.

Name: Anonymous 2008-12-24 11:16

>>49
1 enter 2 + 3 + 4 + 5 +: 10 keypresses
6 <sum>: 2 keypresses

Name: Anonymous 2008-12-24 11:24

I invented a new Lisp dialect just by slamming my dick on the keyboard and groaning "GRUNNUR" loudly.

Name: Anonymous 2008-12-24 11:29

>>67
The pleasure of being "GRUNNUR" inside.

Name: Anonymous 2008-12-24 11:30

>>67
Source or it didn't happen.

Name: Anonymous 2008-12-24 12:09

>>67
Paul Graham?

Name: Anonymous 2008-12-24 12:19

>>70
I'm not paul graham I'm every fucking self taught programmer these days.

Name: Anonymous 2008-12-24 12:36

[expr 3 * (2 * 4 + 3 + 5) + 10 - 7 + 6]

Name: Anonymous 2008-12-24 13:22

[expr 1+call+with*current-continuation]
[expr 1+call-with-current-continuation]

Name: Anonymous 2008-12-24 14:01

>>73
Hit a nerve, huh?

Name: Anonymous 2008-12-24 15:56

postfix was here
infix is loser

Name: Anonymous 2010-11-03 0:29

Name: Anonymous 2010-12-17 1:37

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-02-02 23:34

Name: Anonymous 2011-02-03 3:00

Don't change these.
Name: Email:
Entire Thread Thread List