🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #1057

Re: Length of Arrays in SML

#1057
From: Andrew Koenig
Date: Wed, 06 Jan 1993 09:28
16 lines
990 bytes
In article <C0ECE1.Ju@cs.dal.ca> ssmith@ug.cs.dal.ca (Susan E Smith) writes:

> PROBLEM:  I am using Standard ML (New Jersey), Version 0.66 and I am trying
> to use the Array function "length" to get the length of an array.

The problem is that the built-in function "length" takes a list,
as you found out.  What you want is the "length" in the Array
structure, which is therefore called Array.length:

	val My_Array = arrayoflist ["Hi","My","Name","Is","Bob"];
	Array.length My_Array;

should print 5.
-- 
				--Andrew Koenig
				  ark@europa.att.com
Technical Details
Message-ID: <24561@alice.att.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!linac!att!att!allegra!alice!ark
References: <C0ECE1.Ju@cs.dal.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!linac!att!att!allegra!alice!ark
From: ark@alice.att.com (Andrew Koenig)
Newsgroups: comp.lang.functional
Subject: Re: Length of Arrays in SML
Message-ID: <24561@alice.att.com>
Date: 6 Jan 93 09:28:50 GMT
Article-I.D.: alice.24561
References: <C0ECE1.Ju@cs.dal.ca>
Reply-To: ark@alice.UUCP ()
Organization: AT&T Bell Laboratories, Murray Hill NJ
Lines: 16