Content deleted Content added
m c/e |
Add external links to the current source code for Miranda and a large example of a Miranda program |
||
(40 intermediate revisions by 25 users not shown) | |||
Line 1:
{{Short description|Programming language by David Turner}}
{{
{{Infobox programming language
| name
| logo
| logo caption
| screenshot
| screenshot caption
| file ext
| paradigm
| scope
| released = {{Start date|1985}}▼
▲ | designer = [[David Turner (computer scientist)|David Turner]]
▲ | developer = Research Software Ltd
| latest release version = {{wikidata|property|edit|reference|P348}}
| latest release date
| latest preview version =
| latest preview date
| typing
| implementations
| dialects
| influenced by
| influenced
| |
|
| license = {{wikidata|property|edit|reference|P275}}
▲ | website = {{url|http://miranda.org.uk}}
▲ | wikibooks =
}}
'''Miranda''' is a [[lazy evaluation|lazy]], [[functional programming|purely functional]] [[programming language]] designed by [[David Turner (computer scientist)|David Turner]] as a successor to his earlier programming languages [[SASL programming language|SASL]] and [[Kent Recursive Calculator|KRC]], using some concepts from [[ML (programming language)|ML]] and [[Hope (programming language)|Hope]].
Miranda was first released in 1985
In 2020 a version of Miranda was released as open source under a [[BSD 2-Clause|BSD licence]]. The code has been updated to conform to modern C standards ([[C11 (C standard revision)|C11]]/[[C18 (C standard revision)|C18]]) and to generate 64-bit binaries. This has been tested on operating systems including [[Debian]], [[Ubuntu]], [[Windows Subsystem for Linux|WSL]]/Ubuntu, and [[macOS]] ([[macOS Catalina|Catalina]]).<ref name=opensourcing>{{Cite web|last=Turner|first=David|date=2021-03-22|title=Open Sourcing Miranda|url=http://codesync.global/media/open-sourcing-miranda-david-turner-code-mesh-v-2020-codemeshv2020/|access-date=2021-12-30|website=Code Sync|language=en|publication-place=London|publication-date=November 2020}}</ref><ref>{{Cite web|title=Miranda download page|url=https://www.cs.kent.ac.uk/people/staff/dat/miranda/downloads/|access-date=2021-12-30|website=www.cs.kent.ac.uk}}</ref>
== Name ==
[[File:Miranda - The Tempest JWW.jpg|thumb|right|''Miranda'' by John William Waterhouse, 1917]]
The name ''Miranda'' is taken from the gerundive form of the latin verb {{lang|la|[[:wikt:miror|miror]]}},<ref>{{cite web |url=https://www.cs.kent.ac.uk/people/staff/dat/miranda/name.html |title=About the name Miranda |access-date=2024-05-18}}</ref> meaning "to be admired".
The logo features a rendition by [[John William Waterhouse]] of the character [[Miranda (The Tempest)|Miranda]] from Shakespeare's ''The Tempest''.
== Overview ==
Miranda is a [[lazy evaluation|lazy]], [[functional programming|purely functional]] programming language. That is, it lacks [[Side effect (computer science)|side effect]]s and [[imperative programming]] features. A Miranda program (called a ''script'') is a set of [[equation]]s that define various mathematical [[function (mathematics)|function]]s and [[algebraic data type]]s. The word ''[[
Since the [[parsing]] algorithm makes intelligent use of layout (indentation, via [[off-side rule
[[Comment (computer programming)|Comment]]ary is introduced into regular scripts by the characters <code>||</code> and continue to the end of the same line. An alternative commenting convention affects an entire source code file, known as a "[[Literate programming|literate script]]", in which every line is considered a comment unless it starts with a <code>></code> sign.
Line 46 ⟶ 55:
</syntaxhighlight>
The ''[[
<syntaxhighlight lang="haskell">
Line 86 ⟶ 95:
The notation for function application is simply juxtaposition, as in <code>sin x</code>.
In Miranda, as in most other purely functional languages, functions are [[first-class function|first-class]] citizens, which is to say that they can be passed as [[parameter (computer science)|
<syntaxhighlight lang="haskell">
Line 95 ⟶ 104:
is a roundabout way of creating a function "increment" which adds one to its argument. In reality, <code>add 4 7</code> takes the two-parameter function <code>add</code>, applies it to <code>4</code> obtaining a single-parameter function that adds four to its argument, then applies that to <code>7</code>.
Any function
Thus:
Line 102 ⟶ 111:
</syntaxhighlight>
is the briefest way to create a function that adds one to its argument.
<syntaxhighlight lang="haskell">
Line 139 ⟶ 148:
which gives the list of all prime numbers
<syntaxhighlight lang="
> || The infinite list of all prime numbers.
Line 152 ⟶ 161:
Here, we have some more examples
<syntaxhighlight lang="
max2 :: num -> num -> num
max2 a b = a, if a>b
Line 162 ⟶ 171:
multiply :: num -> num -> num
multiply 0 b = 0
multiply a b =
fak :: num -> num
fak 0 = 1
fak
Line 255 ⟶ 263:
isAvl (N l w r) = and (isAvl l) (isAvl r), if amount ((nodecount l) - (nodecount r)) < 2
= False, otherwise
delete :: * -> tree * -> tree *
delete x E = E
Line 272 ⟶ 280:
==External links==
* {{Official website}}
* [https://codeberg.org/DATurner/miranda The currently maintained open source version] of Professor Turner's interpreter for Miranda.
* [http://bignum.sf.net The infinite precision math library], a large example of programming in Miranda (and Haskell).
{{Programming language}}
{{Authority control}}
Line 279 ⟶ 290:
[[Category:Functional languages]]
[[Category:History of computing in the United Kingdom]]
[[Category:Programming languages created in 1985]]
|