r5rs

Scheme number to list

∥☆過路亽.° 提交于 2019-12-02 01:36:27
问题 I need a subroutine for my program written in scheme that takes an integer, say 34109, and puts it into a list with elements 3, 4, 1, 0, 9. The integer can be any length. Does anyone have a trick for this? I've thought about using modulo for every place, but I don't think it should be that complicated. 回答1: The simplest way I can think of, is by using arithmetic operations and a named let for implementing a tail-recursion: (define (number->list num) (let loop ((num num) (acc '())) (if (< num

R5RS Scheme input-output: How to write/append text to an output file?

谁说我不能喝 提交于 2019-12-02 01:33:08
What is a simple way to output text to file in a R5RS compliant version of Scheme? I use MIT's MEEP (which uses Scheme for scripting) and I want to output text to file. I have found the following other answers on Stackoverflow: File I/O operations - Scheme How to append to a file using Scheme Append string to existing textfile [sic] in IronScheme But, they weren't exactly what I was looking for. ansebbian0 The answers by Charlie Martin, Ben Rudgers, and Vijay Mathew were very helpful, but I would like to give an answer which is simple and easy to understand for new Schemers, like myself :) ;

A “pure” scheme implementation (R5RS) of SHA256?

╄→гoц情女王★ 提交于 2019-11-30 02:31:06
I can use SHA256 in Scheme using external libraries (Java, C or system dependent) or using a specific Scheme implementation (like Chicken e.g.), but I wonder if there is a "pure" scheme implementation. I wrote an implementation today. Alas, R5RS has neither bytevectors nor binary I/O, so this uses the R7RS APIs for bytevectors and binary I/O. It should be easy to bridge those APIs to your Scheme implementation's native APIs (for example, I actually tested my implementation on Racket and Guile). A few notes: This code assumes case-sensitivity. This is the default for R7RS, but not R5RS, so if

ANTLR resolving non-LL(*) problems and syntactic predicates

纵然是瞬间 提交于 2019-11-29 08:50:13
consider following rules in the parser: expression : IDENTIFIER | (...) | procedure_call // e.g. (foo 1 2 3) | macro_use // e.g. (xyz (some datum)) ; procedure_call : '(' expression expression* ')' ; macro_use : '(' IDENTIFIER datum* ')' ; and // Note that any string that parses as an <expression> will also parse as a <datum>. datum : simple_datum | compound_datum ; simple_datum : BOOLEAN | NUMBER | CHARACTER | STRING | IDENTIFIER ; compound_datum : list | vector ; list : '(' (datum+ ( '.' datum)?)? ')' | ABBREV_PREFIX datum ; fragment ABBREV_PREFIX : ('\'' | '`' | ',' | ',@') ; vector : '#('