Scheme عبر الإنترنت - IDE ومحرر ومترجم ومفسّر

شغّل كود Scheme عبر الإنترنت: عرّف الدوال واستخدم التكرار والقوائم و lambda والاستدعاءات الذيلية في مفسّر Scheme يعمل في متصفحك.

R7RS-style Scheme (BiwaScheme 0.8) · يعمل في متصفحك، لذا لا تصل شيفرتك إلى خوادمنا أبدًا.
main.scmScheme
المخرجات

            
        
Ctrl/⌘ + Enter للتشغيل

ميزات مترجم Scheme عبر الإنترنت (بيئة تطوير ومحرّر ومفسّر)

اكتب شيفرة Scheme وشغّلها واختبرها عبر الإنترنت مجانًا. تعمل هذه الصفحة كبيئة تطوير Scheme ومحرّر شيفرة ومترجم ومفسّر في آن واحد: اكتب شيفرتك، واضغط «تشغيل»، وشاهد المخرجات فورًا. كل شيء يعمل في متصفحك، دون أي تثبيت ودون إنشاء حساب.

  • تشغيل الشيفرة فورًا: R7RS-style Scheme (BiwaScheme 0.8)، مع ظهور المخرجات في أقل من ثانية بعد التحميل الأول.
  • محرّر الشيفرة: تلوين الصياغة، وأرقام الأسطر، ومطابقة الأقواس، والإغلاق التلقائي للأقواس.
  • أخطاء واضحة: تظهر رسائل الخطأ والتحذيرات في لوحة المخرجات، كما تظهر على حاسوبك.
  • ملء الشاشة: Ctrl/⌘ + Shift + F، وحجم خط قابل للتعديل، وتخطيط متجاور أو مكدّس، ولوحات قابلة لتغيير الحجم.
  • الحفظ التلقائي: تُحفظ شيفرتك في متصفحك؛ نزّلها باسم main.scm أو انسخها بنقرة واحدة.
  • تجربة آمنة: حدّ زمني وزر إيقاف ينهيان الحلقات اللانهائية.
  • خاص: تعمل بيئة تشغيل Scheme على جهازك، لذا لا تُرفع شيفرتك أبدًا.
  • الوضع الداكن واختصارات لوحة المفاتيح: Ctrl/⌘ + Enter يشغّل الشيفرة.
  • مجاني: بدون تسجيل، وبلا حدود للاستخدام.

تعلّم لغات برمجة أخرى

How to use the online Scheme interpreter

  1. Write or paste Scheme code into the editor. Reset example restores the starter program, which prints a factorial, the first ten Fibonacci numbers and a sum of squares.
  2. Press Run or use Ctrl + Enter (⌘ + Enter on a Mac).
  3. Text written with display, write and newline appears in the Output panel. When the program finishes, the value of the last expression is printed as => value, unless that value is unspecified. Errors are reported with BiwaScheme's own message.
  4. Choose a time limit of 5, 15 or 60 seconds. An endless loop is stopped automatically, and Stop ends a run at once.

The interpreter is only about 0.3 MB, so the page is ready almost immediately. Copy and main.scm save your program, and Full screen (Ctrl/⌘ + Shift + F, Esc to leave) gives the editor the whole window.

Your code runs in a Web Worker inside your browser and is never sent to a server. The editor auto-saves your last program in your browser's local storage, separately for each compiler on this site.

About Scheme and BiwaScheme

Scheme is a small dialect of Lisp. Programs are parenthesised expressions, functions are ordinary values, and recursion is the normal way to loop. Its tiny core makes it a popular teaching language for closures, higher-order functions and interpreters.

This page runs BiwaScheme 0.8.3, a Scheme interpreter written in JavaScript. It follows the R6RS and R7RS standards in style and covers the most common Scheme features. It is not a complete implementation of either standard, though.

What's supported

  • Core forms: define, lambda, let, let*, letrec, if, cond, begin and set!.
  • Lists and higher-order functions: cons, car, cdr, list, map, apply and quoted data such as '(1 2 3).
  • Proper tail calls, so loops written as named let or tail-recursive functions run in constant stack space.

Limitations:

  • No input box. Put test data directly in the program.
  • Not a full standard implementation. Procedures specific to other Schemes, such as MIT Scheme, Racket or Guile, may be missing.
  • Only the code in the editor runs. There are no files to load and no package manager.

Worked example: recursion vs named let

;; Plain recursion: each call waits for the next one to return.
(define (sum-list lst)
  (if (null? lst)
      0
      (+ (car lst) (sum-list (cdr lst)))))

;; Named let: a tail-recursive loop with an accumulator.
(define (sum-to n)
  (let loop ((i 1) (acc 0))
    (if (> i n)
        acc
        (loop (+ i 1) (+ acc i)))))

(display (sum-list '(1 2 3 4))) (newline)   ; 10
(sum-to 100000)                             ; => 5000050000

The last expression is not displayed, so its value appears as => 5000050000. sum-list builds up pending additions, while sum-to calls loop in tail position and behaves like a while loop.

Common pitfalls

  • Forgetting to quote a list. (1 2 3) tries to call 1 as a function and fails. Write '(1 2 3) or (list 1 2 3). The two differ: '(a b) is a list of the symbols a and b, while (list a b) evaluates the variables.
  • define vs let. A top-level define creates a global name. let creates local names that exist only inside its body. Inside a plain let, one binding cannot refer to another, so use let* when a later value depends on an earlier one.
  • display vs write. display prints strings without quotes. write keeps them, which helps when you debug data.
  • Equality. Use = for numbers, eq? for symbols, and equal? to compare lists or strings by content.

Frequently asked questions

Is this a Scheme compiler or an interpreter?

An interpreter. BiwaScheme runs your program directly in the browser with no separate compile step.

Which Scheme standard is supported?

BiwaScheme follows R6RS and R7RS in style and covers the most common features. Standard textbook code that uses define, lambda, let, cond, lists and recursion runs as expected. Code that depends on one implementation's libraries may need changes.

Can I use it for SICP or course exercises?

Yes, for exercises built on core Scheme. If an exercise uses a procedure that is not defined, write a small version of it yourself at the top of the program.

Why does my program print nothing?

Only display, write and newline produce output, plus the => line for the value of the last expression. A program that ends with a define shows no value, because that result is unspecified.

What other languages can I run online?

Try the online Clojure compiler for another Lisp, the online Prolog compiler for logic programming, or browse all online compilers.

آخر تحديث

تم النسخ إلى الحافظة