Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ml > Problems unders...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 9 Topic 869 of 966
Post > Topic >>

Problems understanding sml code

by Thomas Dybdahl Ahle <lobais@[EMAIL PROTECTED] > Apr 19, 2007 at 10:26 PM

Hi, I'm trying to read some (a lot of) sml code.
I've read some tutorials and documentation, so I believe I understand 
most of the sml syntax.
However this line bugs me:

case valOf (List.find match asciiweights) of (x, y, w) =>
      (w, Char.chr (pick (li, ri, x, y)))

Besides I don't know what the valOf function does, I also have two other 
problems.

1) asciiweights is defined by
    val asciiweights = [
      ( 65,  91,   1),
      ( 97,  123,  1),
      ( 48,  58,   2),
      ( 32,  33,   3),
      ( 58,  65,   4),
      ( 91,  97,   4),
      (123,  127,  4),
      ( 33,  48,   4),
      (127,  256, 12),
      (  1,  32,  25),
      (  0,   1, 200)]
   and match is defined by "fun match (x, y, _) = ..."
   
   So how comes match takes three input variables but gets a list?


2) When I read documentation on case of => it normaly looks something like

fun fac n = 
    case n of 
       0 => 1
     | _ => n * fac(n-1);

   Which is "case <number> of <condition> => return value"
   
   But in the line I'm investigating the condition has been switched by 
"(x, y, w)". How can that be?



I hope you can help getting me to understand this. I think sml in general 
looks quite interesting, or at least different :)
 




 9 Posts in Topic:
Problems understanding sml code
Thomas Dybdahl Ahle <l  2007-04-19 22:26:07 
Re: Problems understanding sml code
torbenm@[EMAIL PROTECTED]  2007-04-20 18:09:39 
Re: Problems understanding sml code
jmv16@[EMAIL PROTECTED]   2007-04-20 18:10:37 
Re: Problems understanding sml code
Michael Westergaard <m  2007-04-20 18:10:48 
Re: Problems understanding sml code
Thomas Dybdahl Ahle <l  2007-04-26 18:45:58 
Re: Problems understanding sml code
lobais <lobais@[EMAIL   2007-04-26 18:48:11 
Re: Problems understanding sml code
"Albert Y. C. Lai&qu  2007-05-09 00:05:49 
Re: Problems understanding sml code
jmv16@[EMAIL PROTECTED]   2007-05-09 00:29:22 
Re: Problems understanding sml code
Andreas Rossberg <ross  2007-05-09 00:29:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 5 22:29:53 CDT 2008.