这篇文章小编给大家分享一下在Python实现Scheme的方法,感兴趣的小伙伴一定要耐心阅读完这篇文章 。
文章插图
我们运行python ZhScheme.py
ZhScheme> (tuple 1 2) ['tuple', 1, 2] (1, 2) ZhScheme> (list 5 6 6 ) ['list', 5, 6, 6] [5, 6, 6] ZhScheme> (dict (list (list 5 6) (list 56 34 ))) ['dict', ['list', ['list', 5, 6], ['list', 56, 34]]] {5: 6, 56: 34} ZhScheme> (sin 12) ['sin', 12]-0.5365729180004349ZhScheme> (sin 34) ['sin', 34]0.5290826861200238ZhScheme> (list 3 4 5) ['list', 3, 4, 5] (3 4 5) ZhScheme> (list (list 3 4 5) (list 456 45)) ['list', ['list', 3, 4, 5], ['list', 456, 45]] ((3 4 5) (456 45ZhScheme> (define i 4) ['define', 'i', 4] ZhScheme> ii4ZhScheme> (while (< i 23) (begin (print i) (set i (+ i 1))(if (eq? i 12) break)) ) ['while', [' (for (set i 23) (< i 45) (set i (+ i 2)) (begin (print i) (if (eq? i3) break))) ['for', ['set', 'i', 23], [' (env) ['env'] variables ... + : - : * : / : > : < : >= : <= : = : not : eq? : equal? : max : min : abs : round : car : <function at 0x0000cdr : <function at 0x0000list : <function at 0x000list-ref : <function at 0append : len : map : print : exit : Use exit() or Ctrl-Z plus R open : <function at 0x000call/cc : <function callcc at 0x00procedure? : <built-in function canull? : <function at 0x00number? : <function at 0xstring? : <function at 0xlist? : <function at 0x00struct? : <function at 0xdict? : <function at 0x00int : {} __name__ : math __doc__ : This module is always av mathematical functions defined by th __package__ : __loader__ : , origin='built-in')acos : acosh : asin : asinh : atan : atan2 : atanh : ceil : copysign : <built-in function copycos : cosh : degrees : <built-in function degreerf : erfc : exp : expm1 : fabs : factorial : <built-in function facfloor : fmod : frexp : fsum : gamma : gcd : hypot : isclose : <built-in function iscloisfinite : <built-in function isfiisinf : isnan : ldexp : lgamma : <built-in function lgammalog : log1p : log10 : log2 : modf : pow : radians : <built-in function radiasin : sinh : sqrt : tan : tanh : trunc : pi : 3.141592653589793e : 2.718281828459045tau : 6.283185307179586inf : infnan : nani : 43struct ...
推荐阅读
- Python怎么计算几何图形面积?Python计算四个图形面积的方法
- Python中整数怎么定义?Python整数的特点是什么
- python怎么爬取网页中的图片?这篇文章讲解超级详细
- Python如何保留一位小数输出?Python怎么保留指定小数位
- python中两数相除取余数怎么运算?这两个方法你一定要知道
- Python中while语句怎么使用?while语句使用教程
- python怎么把字符串变成字典?这三个方法你一定要知道
- 如何利用python的input函数输入一个列表?这篇文章教给你方法
- 如何实现python中列表元素转为数字?这篇文章给你带来几个方法
- Python写入中文出错怎么办?问题原因其实是这个