[PR]
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
プログラミング、3DCGとその他いろいろについて
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
(show-paren-mode t) ;思わず"\"C:\\Program Files\\IronScheme\\IronScheme.Console\" -emacs" ;としたくなってしまうかもしれませんが、それでは何故かうまくいきません。 ;%ProgramFiles%を使ってもダメです。 ;きちんと"C:\Program Files\IronScheme"にパスを通して、以下のようにしてください。 ;run-schemeの実装に原因があるかもしれません(※)。 ;※参考:http://saito.s4.xrea.com/wiliki.cgi?Emacs%3Ascheme-args-to-list (setq scheme-program-name "IronScheme.Console.exe -emacs") (run-scheme scheme-program-name) ;エラーの文字化け対策 (modify-coding-system-alist 'process "IronScheme.Console" '(utf-8 . utf-8))
(show-paren-mode t)
(import (rnrs) (ironscheme clr)) (clr-using System) (define myArray (clr-new-array Int32 4)) (do ((index 0 (+ index 1))) ((= index (clr-prop-get Array Length myArray))) (clr-indexer-set! Int32[] myArray index index)) (do ((index 0 (+ index 1))) ((= index (clr-prop-get Int32[] Length myArray))) (clr-static-call Console WriteLine (clr-indexer-get Int32[] myArray index))) (clr-static-call Console ReadLine)
using System; class Program { public static int[] myArray = new int[4]; static void Main() { for (int index = 0; !(index == myArray.Length); index++) { myArray[index] = index; } for (int index = 0; !(index == myArray.Length); index++) { Console.WriteLine(myArray[index]); } Console.ReadLine(); } }
0 1 2 3
36561384 36561408 36561432 36561456
(import (rnrs) (ironscheme clr)) (clr-using System) (define myArray (clr-new-array Int32 1)) (clr-indexer-set! Int32[] myArray 0 42) (display (clr-indexer-get Int32[] myArray 0)) (clr-static-call Console ReadLine)C#でいうとこんな感じです:
using System; class Program { public static int[] myArray = new int[1]; static void Main() { myArray[0] = 42; Console.Write(myArray[0]); Console.ReadLine(); } }
42
(import (rnrs) (ironscheme clr)) (clr-using System) (define myArray (clr-new-array Int32 1)) (define value 42) (clr-indexer-set! Int32[] myArray 0 value) (display (clr-indexer-get Int32[] myArray 0)) (clr-static-call Console ReadLine)
using System; class Program { public static int[] myArray = new int[1]; public static int value = 42; static void Main() { myArray[0] = value; Console.Write(myArray[0]); Console.ReadLine(); } }
42
(import (rnrs) (ironscheme clr)) (clr-using System) (define myArray (clr-new-array Int32 1)) (let ((value 42)) (clr-indexer-set! Int32[] myArray 0 value) (clr-static-call Console WriteLine value)) (clr-static-call Console WriteLine (clr-indexer-get Int32[] myArray 0)) (clr-static-call Console ReadLine)
using System; class Program { public static int[] myArray = new int[1]; static void Main() { int value = 42; myArray[0] = value; Console.Write(myArray[0]); Console.ReadLine(); } }
42 39708184
(import (rnrs) (ironscheme clr)) (let ((value 42)) (clr-static-call System.Console WriteLine "{0} {1}" (clr-call System.Object GetType value) value)) (clr-static-call System.Console ReadLine)
class Program { public static int[] myArray = new int[1]; static void Main() { int value = 42; System.Console.WriteLine("{0} {1}", value.GetType(), value); System.Console.ReadLine(); } }
System.Int32 42
(import (rnrs) (ironscheme clr)) (clr-using System) (define myArray (clr-new-array Int32 4)) (do ((index 0 (+ index 1))) ((= index (clr-prop-get Array Length myArray))) (clr-indexer-set! Int32[] myArray index (clr-cast Int32 index))) (do ((index 0 (+ index 1))) ((= index (clr-prop-get Int32[] Length myArray))) (display (clr-indexer-get Int32[] myArray index)) (newline)) (clr-static-call Console ReadLine)C#版:
using System; class Program { public static int[] myArray = new int[4]; static void Main() { for (int index = 0; !(index == myArray.Length); index++) { myArray[index] = (int)index; } for (int index = 0; !(index == myArray.Length); index++) { Console.WriteLine(myArray[index]); } Console.ReadLine(); } }
0 1 2 3あれ…
(import (rnrs) (ironscheme clr)) (clr-using System) (define myValue 0) (let ((value 42)) (set! myValue value) (clr-static-call Console WriteLine value)) (clr-static-call Console WriteLine myValue) (clr-static-call Console ReadLine)
42 42正常です。
(import (rnrs) (ironscheme clr)) (clr-reference PresentationFramework) (clr-reference PresentationCore) (clr-reference WindowsBase) (clr-using System.Windows) (clr-using System.Threading) (define runApplication (lambda () (define app (clr-new Application)) (clr-call Application Run app (clr-new Window)))) (define staThread (clr-new Thread runApplication)) (clr-call Thread SetApartmentState staThread 'STA) (clr-call Thread Start staThread)
using System.Windows; using System.Threading; class Program { static void runApplication() { var app = new Application(); app.Run(new Window()); } static void Main(string[] args) { var staThread = new Thread(runApplication); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(); } }そうですね
(import (rnrs) (ironscheme clr)) (clr-static-call System.Console WriteLine (+ 1 1)) (clr-static-call System.Console ReadLine)
2です。
(import (rnrs) (ironscheme clr)) (clr-static-call System.Console WriteLine "(- 6 2) = {0}" (- 6 2)) (clr-static-call System.Console WriteLine "(* 6 2) = {0}" (* 6 2)) (clr-static-call System.Console WriteLine "(/ 6 2) = {0}" (/ 6 2)) (clr-static-call System.Console ReadLine)
(- 6 2) = 4 (* 6 2) = 12 (/ 6 2) = 3
(import (rnrs) (ironscheme clr)) (clr-static-call System.Console WriteLine "(/ 7 2) = {0}" (/ 7 2)) (clr-static-call System.Console ReadLine)この結果は
(/ 7 2) = 7/2
(import (rnrs r5rs (6)) (ironscheme clr)) (clr-static-call System.Console WriteLine "(quotient 7 2) = {0}" (quotient 7 2)) (clr-static-call System.Console WriteLine "(modulo 7 2) = {0}" (modulo 7 2)) (clr-static-call System.Console WriteLine "(modulo 7 -2) = {0}" (modulo 7 -2)) (clr-static-call System.Console WriteLine "(modulo -7 2) = {0}" (modulo -7 2)) (clr-static-call System.Console WriteLine "(modulo -7 -2) = {0}" (modulo -7 -2)) (clr-static-call System.Console WriteLine "(remainder 7 2) = {0}" (remainder 7 2)) (clr-static-call System.Console WriteLine "(remainder 7 -2) = {0}" (remainder 7 -2)) (clr-static-call System.Console WriteLine "(remainder -7 2) = {0}" (remainder -7 2)) (clr-static-call System.Console WriteLine "(remainder -7 -2) = {0}" (remainder -7 -2)) (clr-static-call System.Console ReadLine)
(quotient 7 2) = 3 (modulo 7 2) = 1 (modulo 7 -2) = -1 (modulo -7 2) = 1 (modulo -7 -2) = -1 (remainder 7 2) = 1 (remainder 7 -2) = 1 (remainder -7 2) = -1 (remainder -7 -2) = -1