syntax across languages

Pixel pixel@mandrakesoft.com
11 Feb 2002 12:51:07 +0100


ketil@ii.uib.no (Ketil Z. Malde) writes:

[...]

> The . operator is used for package scope when packages (modules) are
> imported "qualified".

ok

> Indentation can optionally be replaced by { ; and }.

ok

> In addition to . function composition, there's also $ function application,
> which often is more practical to use.

I could put it in "grouping expressions":

$ ...       Haskell

WDYT?

> 
> Under "control flow", there's also 
> 
>         case x of 
>                v0 -> e0
>                v1 -> e1
>                ...
>                otherwise -> e

ok

> 
> and 
> 
>         | bool0     = e0
>         | bool1     = e1
>         | ...
>         | otherwise = en

i put this one in category "if_then_else" (just like Lisp's "cond")

uh... how can this be one-line written?

> 
> I'm not sure if "iterate" counts as loop forever?

I don't think there can be a "loop forever" construct in haskell?

in OCaml, it is simply:
let loop(f) = f() ; loop(f)
and is only useful together with exceptions and side-effects.

> 
> I can't remember any %-based sprintf off the top of my head, but hey,
> who'd want one anyway?

me! I've always wondered how you internationalize a program without it?

eg: 
"This encryption key is too simple (must be at least %d characters long)"
"The package %s needs to be installed. Do you want to install it?"

(I agree you don't need the full power of sprintf for this)

> (!!) accesses an indexed character

ok

> As for "duplicate n times", I suppose you'll
> have to combine the two Prelude functions (concat . repeat n),
> while (map toUpper)/(map toLower) converts the case of strings, 
> , and substrings of lenght l at position
> i can be extracted by (take l . drop i).  (Remember that strings are
> lists!) 

i don't put any non-simple functions, the main aim is not to show how it can
be done, but what are the various names used in various languages.

> Dictionaries can (inefficiently in some cases) be constructed using
> assoc lists, with the "lookup" function as accessor.

there's a special entry for it: 'lookup an element in a association list'

Thanks!