1
Software & Sourcecode
Navigation
Portal
Index
Online Projects
Download
Galerie
Libary

Main
back
[*]class
(define class1%
(class object%
(super-new)
(define/public func1
(lambda()
(displayln "func1-1")(newline)))))
(define sub-class%
(class class1%
(super-new)
(define func1
(lambda()
(displayln "func1-2")))
(override func1)))
(send (new class1%) func1)
(send (new sub-class%) func1)
[*]struct
(struct point (x y) #:inspector #f)(point 3 5)(point 3 5)
(struct struct1(a b c g [d #:mutable]))(define s1(struct1 0 7 6 1 2))
(set-struct1-d! s1 8)(struct1-d s1)
(struct struct2(a b [c #:auto]) #:auto-value 100)
(define s2(struct2 1 2))(struct2-c s2)
(struct struct3 (v1 v2) #:property prop:procedure (struct-field-index v1))
(define s3 (struct3 add1 100))(s3 100)(struct3-v2 s3)
(struct struct4 (v1 v2) #:transparent) (equal? (struct4 1 2) (struct4 1 2))
(struct struct5 (v1 v2) #:prefab)(struct5? `#s(struct5 1 2))
(struct struct6 (v1 [v2 #:mutable]) #:prefab)
(struct struct7 struct6 ([v1 #:auto]) #:prefab #:auto-value 100)(struct7 "s1" "s2")
(struct struct8 (name) #:transparent #:guard
(lambda (name type-name) (cond
[(string? name)name][(symbol? name)(symbol->string name)]
[else(error type-name "bad name: ~e" name)])))
(define s8(struct8 `abc))s8
[*]module
>>main
(require "data.rkt")
(func 9)
>>data.rkt
(define func ...)
(provide(all-defined-out))
(module m1 racket/base
(define func
(lambda(x)(odd? x)))
(provide (all-defined-out)))
(require `m1)
(func 9)
(module m2 racket/base
(define reverse
(lambda(ls)
(cond[(null? ls)`()]
[else(append(reverse(cdr ls)) (list(car ls)))])))
(provide reverse))
(require `m2)
[*]unit(require racket/unit)
(define-signature sig1(proc1 v1))
(define-signature sig2(v2))
(define-unit unit1@
(import)
(export sig1)
(define v1 9)
(define proc1(lambda(x)(display x))))
(define-unit unit2@
(import sig1)
(export sig2)
(define v2 (proc1 v1)))
(define-values/invoke-unit/infer unit1@)
(proc1 9)
[*]contract
(provide (contract-out [v1 positive?]))
(define v1 4567)
(provide (contract-out [v2 (and/c number? positive?)]))
(define v2 5678)
[*]syntax
(define-syntax-rule (syntax1 a) (display a))(syntax1 1)
(define-syntax syntax2
(syntax-rules()
[(syntax a)(display a)]
[(syntax2 a b)(display (+ a b))]))(syntax2 456)
(define-syntax syntax3
(syntax-id-rules(set!)
[(set! syntax3 a)(display a)]
[syntax3(display "")]))(set! syntax3 589)
(define-syntax (syntax4 stx)
(syntax-case stx ()
[(_ case1 case2) (with-syntax ([helper (printf"...")])
#`(begin
(define (case1 x)
(printf "~a" x)helper)
(define (case2 x)
(printf "~s" x)helper)))])) (syntax4 c1 c2) (c1 86)
(define-syntax-rule
(let: ([v r] ...) body ...)
((lambda (v ...) body ...) r ...))
(let: ([a 1] [b 2]) (+ a b))
(require (for-syntax syntax/parse))
[*]database
(require db)
(define db1(sqlite3-connect #:database `temporary #:mode `create))
(query-exec db1 "create table t1(id integer primary key,n varchar(50))")
(query-exec db1 "insert into t1 values($1,$2)"0 "n1")
(query-row db1 "select n from t1 where id = 0");value/list/rows
(query-exec db1 "update t1 set id = 1 where id = 0")
(query-exec db1 "delete from t1 where id > 0")
[*]txt-file
(define file(open-output-file "file.txt" #:exists `replace))
(define writeFile(lambda(txt)(write txt file)))
(writeFile "txt")
(close-output-port file)
(define in (open-input-file "file.txt"))
(define (readFile in)(printf "~s" (read in)))
(readFile in)
(close-input-port in)
(file->string "txtDocumentsdrRacket.txt")
[*]file/path
(file-exists? path)
(find-executable-path path)
(file-or-directory-permissions path)
(directory-list path)
(current-directory)
[*]gui
(require racket/gui)
(define frame (new frame%[label "testframe"][width 300][height 300]))
(define menu-bar(new menu-bar%[parent frame]))
(define menu(new menu%[label "menu"][parent menu-bar]))
(define menu-item(new menu-item%[label "menu-item"][parent menu]
[shortcut #A][shortcut-prefix (list `ctl)]
[callback (lambda(menu-item event)(send dc set-text-foreground "red")
(send dc draw-text "test" 5 5)(send dc draw-line 3 7 9 22))]))
(define checkable-menu-item(new checkable-menu-item%[label "checkable"]
[parent menu][shortcut #V][shortcut-prefix (list `ctl)][checked #t]
[help-string "helpstring"]
[callback (lambda(checkable event)(send frame set-label "text"))]))
(define choice(new choice%[label "choice"][parent frame]
[choices (list "1" "1" "1")]
[callback (lambda(choice event)
(send button set-label (format "~a"(send choice get-selection))))]))
(define msg(new message%[parent frame][label "msg"][auto-resize #t]))
(send msg set-label "neuer text")
(send msg auto-resize)
(define test(lambda(x)(display (+ 1 x))))
(send frame show #t)
(send frame create-status-line)
(send frame get-menu-bar)
(define bitmap(read-bitmap "C:Usersimg.jpg"))
(send frame set-icon bitmap)
(send frame set-status-text "status-text")
(send frame has-status-line?)
(define button(new button%[label "button"][parent frame]
[callback (lambda(button event)(send button set-label "settext"))]))
(define canvas(new canvas%[parent frame]))
(define dc(send canvas get-dc))
(define check1 #f)
(define check-box(new check-box%[label "check"][parent frame]
[callback (lambda(check event)
(set! check1 (send check-box get-value))(display check1))]))
(send check-box set-value #t)
(define mouse-event(new mouse-event%[event-type `enter][x 5][y 0]))
(define timer(new timer%
[notify-callback (lambda()(display (send mouse-event button-down? `left)))]))
(send timer start 100 #f)
(begin (new popup-menu%[title "poptxt"]
[popdown-callback (lambda(pop event)(test 5))]))
(define radio-box(new radio-box%[label "radio"][choices `("1" "2" "3")]
[callback (lambda(radio event)
(display (send radio-box get-selection)))][parent frame]))
(define combo-field(new combo-field%[label "radio"][choices `("1" "2" "3")]
[callback (lambda(cfield event)(display (send combo-field get-value)))]
[parent frame]))
[*]draw
(require racket/draw)
(define target (make-bitmap 300 300))
(define dc (new bitmap-dc% [bitmap target]))
(send dc draw-rectangle 0 10 30 10)
(send dc draw-line 0 0 30 30)
(send dc draw-line 0 30 30 0)
(send dc erase)
(send dc draw-rectangle 0 0 100 30)
(define-values (w h d a)
(send dc get-text-extent "text"))
(send dc draw-text "text" (/ (- 100 w) 2) (/ (- 30 h) 2))
(send target save-file "img1.png" `png)
[*]fractal >> quelle
(require htdp/draw lang/posn)
(define LIMIT 3)
(start 399 399)
(draw-solid-line (make-posn 100 100)(make-posn 100 200) `blue)
(define draw-square(lambda(a b c d)
(and
(draw-solid-line a b `blue)
(draw-solid-line b c `darkblue)
(draw-solid-line c d `aquamarine)
(draw-solid-line d a `skyblue))))
(draw-square (make-posn 100 100)(make-posn 100 200)(make-posn 200 200)(make-posn 200 100))
(define angular-displacement(lambda(angle side point)
(make-posn(+ (posn-x point)(* side(cos(* 2 pi (/ angle 360)))))
(+ (posn-y point)(* side(sin(* 2 pi (/ angle 360))))))))
(define pythagtree(lambda(a side angle)
(cond[(< side LIMIT)#t]
[else (and
(draw-square a
(angular-displacement(- angle 90)side a)
(angular-displacement(- angle 45)(* (sqrt 2)side)a)
(angular-displacement(+ angle 0)side a))
(pythagtree
(angular-displacement(- angle 90)side a)
(/ side (sqrt 2))
(- angle 45))
(pythagtree
(angular-displacement
(- angle 71.5)(*(* 1.11925(sqrt 2))side)a)
(/ side (sqrt 2))
(+ angle 45)))])))
(start 1000 1000)
[*]racketSource in subdirs
for([path(in-directory)]#:when (regexp-match? #rx"[.]$" path))(printf "~a" path))
[*]basic-auth
#lang web-server/insta
(define (start req)
(match (request->basic-credentials req)
[(cons user pass)
(response/xexpr
`(html (head (title "Basic Auth Test Panel"))
(body (h1 "User: " ,(bytes->string/utf-8 user))
(h1 "Pass: " ,(bytes->string/utf-8 pass)))))]
[else (response 401 #"Unauthorized" (current-seconds) TEXT/HTML-MIME-TYPE
(list (make-basic-auth-header (format "Basic Auth Test: ~a" (gensym))))
void)]))
[*]write html
(require xml)
(define web1 xml-box...")
(define web01-xml (xexpr->xml web1))
(with-output-to-file "C:pathTempweb01.html"
(lambda()
(write-xml/content web1-xml)) #:exists `replace)
[*]browser
(require browser)
(define hyper-frame
(new hyper-frame%
[label "Browser"]
[start-url "http://www.new-lv.de/"]
[width 400][height 300]))
(send hyper-frame show #t)
[*]xml
(require xml)
(define web1 ;menu -> einf?gen -> xml-kasten einf?gen
xml-kasten>>>[xml-box some text])
(write-xml/content(xexpr->xml web1))
(with-output-to-file "C:Users/User/Desktop/web1.html"
(lambda()
(write-xml/content(xexpr->xml web1)))#:exists `replace)
(write-xml
(with-input-from-file "C:Users/User/Desktop/web1.html" read-xml))
(require browser)
(open-url(string-append "file:"
(path->string(build-path "C:Users/User/Desktop/web1.html"))))
[*]servlet
#lang web-server/insta
(require web-server/web-server web-server/servlet-env)
(define (start req)(response/xexpr `(html (head (title "Hello world!"))(body (p "Hey out there!")))))
(serve/servlet start #:port 8888)
[*]html-code->string
(require net/url)
(define text
(regexp-match #px".*"
(get-pure-port (string->url "new-lv.de"))))
[*]subprocess
(define-values (p stdout stdin stderr)
(subprocess #f #f #f "C:/Program Files (x86)/../*.exe" "-w"))
[*]shell
(shell-execute #f "http://racket-lang.org" "" (current-directory) `sw_shownormal)
[*]plot
(require plot)
(plot (function sin -5 5))
(plot (function sin) #:x-min -5 #:x-max 5 #:y-min -5 #:y-max 5)
(plot (lines (map vector xs (map sqr xs))))
[*]thread
(thread
(lambda()
(letrec
([loop
(lambda()
(sleep 4.0)
(loop))])
(loop))))
[*]engine
(require racket/engine)
(define engine:
(engine
(lambda (_)(let loop ()(sleep 1)(loop)))))
(engine-run(expt 100 100)engine:)