翻訳と辞書
Words near each other
・ REF
・ Ref Sanchez
・ Refaat Al-Gammal
・ Refaat El-Sayed
・ Refaat Ismael
・ Refactorable number
・ Refael (Rafi) Benvenisti
・ Refael Reuvain Grozovsky
・ Refael Shapiro
・ Refafu
・ Refah Bank
・ Refah Chain Stores Co.
・ Refah School (Tehran, Iran)
・ Refah tragedy
・ Refahiye
Refal
・ Refanezumab
・ Refat Chubarov
・ Refback
・ Refbase
・ Refco
・ RefDB
・ RefDB (chemistry)
・ RefDB (disambiguation)
・ Refectory
・ Refectory Church (Pechersk Lavra)
・ Refectory table
・ Refeeding syndrome
・ Refen
・ Refer


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Refal : ウィキペディア英語版
Refal

Refal (Recursive functions algorithmic language) "is a functional programming language oriented toward symbol manipulation", including "string processing, translation, () artificial intelligence". It is one of the oldest members of this family, first conceived in 1966 as a theoretical tool with the first implementation appearing in 1968. Refal was intended to combine mathematical simplicity with practicality for writing large and sophisticated programs.
Unlike Lisp, Refal is based on pattern matching. Its pattern matching works in the forward direction rather than backwards (starting from the goal) as in Prolog.
Very important is the difference between data structures and their use in Refal and most other high-level languages. The basic data structure of Lisp and Prolog is a linear list consed up from the beginning. Refal lists are built and scanned from both ends, and pattern matching allows to match against nested lists as well as the top-level one. (In effect, the basic data structure of Refal is a tree rather than a list). According to the authors, this gives freedom and convenience in creating data structures while using only mathematically simple control mechanisms of pattern matching and substitution.
Refal also includes a feature called the ''freezer'' to support efficient partial evaluation.
Refal can be applied to the processing and transformation of tree structures, similarly to XSLT.〔http://www.refal.org/english/xmlref_1.htm〕
== Refal Basics ==

A Refal Hello World example is shown below.
$ENTRY Go
Hello
The program above includes two functions named Go and Hello. A function is written as the name of the function followed by the function body in curly braces. The Go function is marked as the entry point of the program using the $ENTRY directive.
One could think of expressions in the function bodies as function "calls" in Lisp-like syntax. For example, the Hello function appears to call the built-in Prout function with the string 'Hello world' as the argument. The meaning and the mechanism of the call, however, is quite different. To illustrate the difference, let us consider the following function that determines whether a string is a palindrome.
Pal
This example shows a function with a more complex body, consisting of four ''sentences''. A sentence begins with a ''pattern'' followed by an equal sign followed by a general ''expression'' on the right hand side. A sentence is terminated with a semicolon. For example, the pattern of the second sentence of the function is "s.1" and the expression is "True".
As the example shows, patterns include ''pattern variables'' that have the form of a character identifying the type of the variable (what the variable matches) followed by the variable identifier. The variables that begin with an "s" match a single symbol, those that begin with an "e" match an arbitrary expression. The variable identifier can be an arbitrary alphanumeric sequence optionally separated from the type identifier by a dot.
A function executes by comparing its argument with the patterns of its sentences in the order they appear in the definition, until the first pattern that matches. The function then replaces the argument with the expression on the right hand side of the matched sentence.
If the result of a function application includes a subexpression in angle brackets (as it will after the third sentence of our example is applied), the result is further processed by Refal by invoking the function identified by the first symbol in the brackets. Execution stops when the result has no more angle brackets to expand in this way.
The function Pal can thus be read informally as: "If the expression is empty, replace it with True. Otherwise if the expression is a single symbol, replace it with True. Otherwise if the expression is a symbol followed by an arbitrary expression e.2 followed by the same symbol, replace it with the expression . (In other words, throw away the two identical symbols at the beginning and the end and recurse). Otherwise replace the expression with False. (The pattern e.1 always matches)."
The following are three step-by-step execution traces annotated with the sentence numbers applied at each step to produce the next
(#3)
(#3)
(#1)
True
(#3)
(#2)
True
(#3)
(#3)
(#3)
(#4)
False
We can now see that the Hello World example in fact executes as the sequence of the following expression transformations:
Seed the machine with the initial expression marked by $ENTRY:
(apply the sentence in Go)
(apply the sentence in Hello)
(Prout is a built-in that prints and expands to nothing)
(nothing to apply; stop)

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Refal」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.