JAVA LISP Upthksv
iPjLISPJAVA
LISPƂFORTRAN̎炢ɌÂłAŋ߂̊w猩ƁAяLߋ̌ɉf邩܂B́AmȂƂ̂ŁAFcqJ̉̂uQOIŌ̒^{[JvȂǂƕĂ肪ĕĂ邩AȌ̒ႢƂɂȂĂ܂̂łB
uQOIŌ̉̕PvƂĂACh ̎r[N̉̂牽{Ȃ̂Ɣ͂łi邢͒ĂȂAn̎ɉĂ jBlɖ{̃vO}͈xLISPɗ܂B ǂłPROLOG̋ȏuPROLOG PROGRAMMING FOR ARTIFICIAL INTELLIGENCEvɂ́A
vO‾Ỏ҂͋ߑLISPł
ƎvƏĂ܂B @LISP͔ł̂ŁAvȌlƌĂт܂傤B bVBȂǂƂ͑ɂȂȂ̂łB
VBW[Ȃ̂BASIC炵ł͂ȂāAMSWindows̃vO‾OpVB`[jOĂ邩łāA܂WindowsOŜWȏ̃VFAĂ邩ɑȂ܂B ԂAقOSłVB͉̖ɂ܂B LISP̂̂܂܂ł͂ȂAIuWFNgwIȊg{ꂽA܂܂ȌIȑāACOMMO/span>
}V ̃Xvł̍¥j
@
ł͂ŁANX̋̓IȎĂ݂܂傤B
ʓIɂ͘_vƕvɂ̓Mbv̂łAł͏o肻vw͂Ă܂B
}R̃NX¥̂܂Őv܂B
(}W ۂ̃NX)------------
package quilt; import java.io.*; interface SExpression { public void print(DataOutputStream dos) throws IOException; }̓[_[݂̎̂JĂ܂̂ŁAƂ肠vg̃¥bh`ꂽC^[tFCXƂȂĂ܂B
[_[͍̕¥͂ȂȂȂ̂Ōq悤ɁALisp{̂̃[_[ɉ͂C܂B̃NXEvaluatorȂǂ
ljď͂ƕGɂȂĂł傤B
精神病理学の歴史とは何か
XgQ ------ Integer.java ------------ package quilt; import java.io.*; public class Integer extends Number { private int val; public Integer() { val = 0; } public Integer(int i) { val = i; } public int valueOf() { return val; } public java.lang.String toString() { return "" + val; } public Integer add(Integer i) { return new Integer(val + i.valueOf()); } public Integer subtract(Integer i) { return new Integer(val - i.valueOf()); } public Integer multiply(Integer i) { return new Integer(val * i.valueOf()); } public Integer divide(Integer i) { return new Integer(val / i.valueOf()); } public void print(DataOutputStream dos) throws IOException { try { dos.writeInt(val); } catch (IOException e) { throw e; } } } XgQ͐̃NXłD̒ʂAprintȊO͎Zp¥bh`Ă܂BɃV{NXA
iXgRjAXgNXiXgSjĂ݂܂傤B
XgR@ ------ Symbol.java ------------ package quilt; import java.io.*; public class Symbol extends Atom { java.lang.String str = null; public Symbol() { } public Symbol(java.lang.String s) { str = new java.lang.String(s); } public Symbol(char[] ca) { str = new java.lang.String(ca); } public void print(DataOutputStream dos) throws IOException { try { dos.writeChars(str); } catch(IOException e) { throw e; } } } XgS@ ------ List.java ------------ package quilt; import java.util.*; import java.io.*; public class List extends LinkedList implements SExpression { public List() { super(); } /**********RgAEg ************ public void add(int index, SExpression element) { super.add(index, element); } public void add(SExpression element) { super.add(element); } public boolean addAll(Collection c) { super.addAll(c); } public void addFirst(SExpression element) { super.addFirst(element); } public void clear() { super.clear(); } public Object clone() { return super.clone(); } public Object get(int index) { return (SExpression)super.トップの基本的なスキンケア製品get(index); } public Object remove(int index) { return super.remove(index); } public boolean remove(SExpression e) { return super.remove(e); } public Object removeLast() { return super.removeLast(); } public Object set(int index, SExpression e) { return super.set(index, e); } ****************************/ public void print(DataOutputStream dos) throws IOException { try { int n = size(); dos.writeChars("("); for (int i = 0; i < n; i++) { SExpression sexp = (SExpression)get(i); sexp.print(dos); if (i < n - 1) dos.writeChars(" "); } dos.writeChars(")"); } catch (IOException e) { throw e; } } }
V{NX́AString̃oĂ邾̃VvȃNXłBV{͕ϐƂĎĝŁA
V{̃e[unbVe[uŊǗȂȂ܂B
CȂǂLISPJꍇAɍȃnbVe[uĂ̂łAQUILTSchemeł́A
JavaWHashtableg܂B
XgNXSexpressonCvgALinkedListhꂽNXƂȂĂ܂B́A¥[X
cĂ悤add()remove()Ȃǂ̂Rei¥bhI[o[ChȂȂȂƍlĂ܂B
C++łł傤BƂ낪JavȁꍇAẽ¥bĥ܂܌ĂׂΎ邱ƂɋCÂ܂B
ŃXg̃¥bhׂ͂ăRgAEgA߂ĒPȃNXɂȂĂ܂B
ŌɃ[_[̃¥[Xт̎s{Lɍڂ܂BiXgTj̃R[h͂܂v‾eBuȂ̂łA
ɂ͑傫ύXƎv܂B
̗łKłBLISPVXe͈ʓI}X̂悤ȍ¥Ă܂B
iwCvOubNIIIx^A^AXL[jB
@
i}X LISP̍¥j
́A[_[ƃv^[̏܂B
Xy[X܂ł̂ŁA̓[_[ƃv^[̏ڍׂƃGoGC^[i]j܂B
iRj̃VXe̖ڕW
ł́ALISPgĂ͉悤Ƃ̂ł傤D܂ʓIȗprƂāA
@JAVAAvP[ṼJX^}CYpXNvgƂĎgDMuleEmacs Lisp̂悤Ȃ́AMS-OfficeȂVBA݂Ȃ̂łB
どのようにすぐにまたは父親のために新生児をテストすることができます
AQPIIȃAvP[VƂ̂͂ł邾[U̍Ƃȗł̂łȂȂ܂D
[UAVX^------------- package quilt; import java.io.*; import java.util.*; public class lisp { static final int MaxToken = 32; SExpression nil, endOfRead; private String line; static Hashtable symbolTable = null; public lisp() { symbolTable = new Hashtable(); } public static void main(String[] args) { lisp vLisp = new lisp(); vLisp.invokedStandalone = true; DataInputStream in = new DataInputStream(System.in); DataOutputStream out = new DataOutputStream(System.out); for(;;) { try { out.writeUTF("QLisp> "); out.flush(); SExpression exp = reader(in); printer(exp, out); } catch(Exception e) { e.printStackTrace(); } } } static void printer(SExpression se, DataOutputStream dos) throws IOException { if (se == null) return; try { se.print(dos); } catch (IOException e) { throw e; } } static SExpression reader(DataInputStream dis) throws Exception { try { if (skipSpace(dis) == false) return new Nil(); char ch = peekChar(dis); if (isEscape(ch)) return escape(dis); else if (isDigit(ch)) return makeNumber(dis); else //if (isSymbol(ch)) return makeSymbol(dis); // else // return new Nil(); } catch (Exception e) { throw e; } } static boolean skipSpace(DataInputStream dis) throws IOException { char ch = 0; try { for (;;) { do { ch = dis.readChar(); dis.mark(100); } while (Character.isWhitespace(ch)); dis.reset(); if (ch != 0 && ch != ';') { return true; } if (dis.readLine() == null) return false; } } catch (IOException e) { throw e; } } static boolean isEscape(char ch) { switch(ch) { case ' ': case '#': case '.': case ';': case '(': case ')': case '[': case ']': case '¥¥': case '^': case ',': case '|': // case '¥': return true; default : return false; } } static boolean isDigit(char ch) { if (Character.
0 コメント:
コメントを投稿