0

For Standard ML (SMLNJ), for the foldr and foldl functions, what is the correct way to use the multiplication operator?

Using foldr (op *) 1 [1,2,3]; gives an error

Standard ML of New Jersey v110.78 [built: Thu Aug 31 03:45:42 2017]

  • stdIn:1.12 Error: unmatched close comment
  • stdIn:1.9-1.18 Error: syntax error: deleting OP INT LBRACKET

It appears that the * has other overloads.

Eugene
  • 10,957
  • 20
  • 69
  • 97

1 Answers1

0

Whitespace normally doesn't matter for SMLNJ. But for the multiplication (asterisk) operation it does.

Make sure you have a space between the asterisk and the closing parenthesis * ) or it will be interpreted as an unopened comment *).

foldr (op * ) 1 [1,2,3];

Eugene
  • 10,957
  • 20
  • 69
  • 97