博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Racket Cheat Sheet
阅读量:6955 次
发布时间:2019-06-27

本文共 3460 字,大约阅读时间需要 11 分钟。

Racket Cheat Sheet

来源  http://docs.racket-lang.org/racket-cheat/index.html?q=Racket%20Cheat%20Sheet

 

Essentials

Sites    
Community      
Put   "Hello, world!" in hello.rkt and run racket hello.rkt
Primitives

Numbers

integer 1 rational  1/2  complex 1+2ifloating 3.14 double 6.02e+23 hex #x29 octal #o32 binary #b010101
Arithmetic                 ... 
Compare     
Bitwise    
Format  
Test   ...  ...     
Misc
Match Pattern (?  n) 42

Strings

"Racket" quoting "a \" approaches!"unicode "λx:(μα.α→α).xx"
Create    
Observe    
Modify  
Test   
#rx"a|b" #rx"^c(a|d)+r$"    
Match Pattern (?  s) "Banana?"

Bytes

#"rawbytes\0"
Create  
Numbers  
Observe   
Modify   
Conversion  
Test  
Match Pattern (?  b) #"0xDEADBEEF"

Other

Booleans #t #f  
#\a #\tab #\λ    ...  ...
'Racket    
Boxes     
Procedures       
Void  
Undefined
Data

Lists

Create    
Observe         
Use      
Modify   ...      
Match Pattern ( a b c) ( a b more)( top more ...)

Immutable Hash

Create  
Observe     
Modify   

Vector

Create   
Observe   
Modify    
Match Pattern ( x y z) ( x ycalabi–yau ...)

Streams

Create   
Observe   

Mutable Hash

Create  
Observe     
Modify   
Systems

Input/Output

Formatting      
Input   
Output    
Ports and Files         ...

Files

Paths    ...
Files         

Miscellaneous

Time    
Command-Line Parsing
FFI   ...  

Networking

TCP    
HTTP     
URLs   
Email  ...
JSON  
XML   
Databases        ...

Security

Custodians   
Sandboxes  

Concurrency

Threads   
Events     ...
Channels  
Semaphores  
Async Channels   

Parallelism

Futures    ...
Places     ...
Processes  

 

Syntax (Beginner)

Basics

Modules ( main body ...) 
( test body ...) 
( mod-path) (id)
S-expressions  '(a b c)  `(1 2 ,( 1 2))
Procedure Applications (fn arg1 arg2
 (fn arg1 #:keyarg2
( fn arg1 ( arg2))
Procedures ( (x) x) ( (x) x) 
( (x [opt 1]) ( x opt)) 
( (x #:req key) ( x key)) 
( (x #:opt [key 1]) ( xkey))
Binding ( ([x 1] [y 2]) ( x y)) 
( ([x 1] [x ( x 1)]) x)
Conditionals ( ( x) 0 ( 1 x)) 
( [( x) 0] [( x)1] 
      [ "impossible!"]) 
 
Definitions ( x 1) 
( (f y) ( x y))
Iteration   
Blocks   
Require Sub-forms      ...
Provide Sub-forms   ... 

Structures

Definition ( dillo (weight color))
Create ( danny (dillo 17.5'purple))
Observe (dillo? danny) (dillo-weightdanny) (dillo-color danny)
Modify ( dillo danny([weight 18.0]))
Match Pattern (dillo w c)

Pattern Matching

Basics ( value [pat body] ...)
Definitions ( pat value)
Patterns (quote datum) ( lvp ...)(list-no-order pat ...) (vectorlvp ...) (struct-id pat ...)(regexp rx-expr pat) (or pat...) (and pat ...) (? expr pat...)
Syntax (Intermediate)

Basics

Mutation
Exceptions   
Promises   
Continuations     
Parameters  
External Files Needed at Runtime
Continuation Marks  
Multiple Values    

Contracts

Basics       ...
Functions   
Application   

Iteration

Sequences            
Generators   

Structures

Sub-structures ( 2d (x y)) ( 3d2d (z)) (2d-x (3d 1 2 3))
Mutation ( monster (type [hp#:mutable])) ( healie(monster 'slime 10)) (set-monster-hp! healie 0)
Transparency ( cash ($ ¢)#:transparent) ( (cash 5 95))
Printing ( nickname [n v]#:methods [( (write-proc nn pmode) ( p (nickname-nnn)))]) ( (nickname"evens" ( 0 100 2)))
Serialization ( txn (who what where)#:prefab) ( (txn"Mustard" "Spatula""Observatory"))

Generics

Definition
Instantiation ( even-set () #:methods [( (st i) ( i))])

Classes

Definition  
Instantiation   
Methods     
Fields  
Mixins
Traits    ...
Contracts    
Syntactic Abstractions
Definition    
Templates   
Parsing ()-Syntax   
Syntax Objects   ...  
Transformers      ...
Syntax Parameters  
Parsing Raw Syntax   
Tools

Inspection raco pkg show
Finding
Installing raco pkg install
Updating raco pkg update
Removing raco pkg remove

Miscellaneous

raco make program.rkt
raco test program.rkt a-directory
raco exe program.rkt
Extending DrRacket
Slides   

 

================= End

 

转载地址:http://ssvil.baihongyu.com/

你可能感兴趣的文章
2019年人工智能硬件与应用大趋势
查看>>
2018 FDA获批医疗器械盘点,政策红利能否继续?
查看>>
Git协同工作流介绍
查看>>
语音识别实时对比(百度收费 VS SpeechTexter免费)
查看>>
2018智能汽车盘点,新旧造车势力的智能化PK
查看>>
阿里云服务器的配置及搭建教程
查看>>
书籍:python游戏编码 Coding Games in Python - 2018
查看>>
Docker镜像细节
查看>>
如何通过脚本实现数据动态更新
查看>>
远禾科技出席阿里ASRC生态大会 并参与安恒西湖论剑
查看>>
使用eclipse创建web项目的项目图文步骤
查看>>
window powershell 获取所有用户的最后登录时间
查看>>
ApiPost的环境变量的定义和使用「ApiPost环境变量」
查看>>
智能相机是工业深度学习的第一步
查看>>
Android 代码中动态设置字体大小-TextView.SetTextSize()
查看>>
Percona XtraBackup 8.0, 安装与测试
查看>>
GeoMesa时空基础及应用场景
查看>>
使用Intellij Idea打包java为可执行jar包
查看>>
智能手机 3D 视觉之战:苹果不再一枝独秀,Android 全面崛起
查看>>
用AI教直男恋爱、手残做菜、防诈骗,愚人节的百度、阿里、腾讯好嗨哟!
查看>>