scheme

How is “letrec” implemented without using “set!”?

ε祈祈猫儿з 提交于 2019-12-05 06:07:11
How can letrec be implemented without using set! ? It seems to me that set! is an imperative programming construct, and that by using it, one loses the benefits of functional programming. I know usually we ask content to be copied but there is no short answer to your question. http://www.cs.indiana.edu/~dyb/pubs/fixing-letrec.pdf No. Just because a functional feature is implemented with imperative code behind the scenes, that doesn't make the feature be imperative. Our computing machines are all imperative; so at some point all functional code must be implemented by translation into imperative

Some Macro terms in Racket

女生的网名这么多〃 提交于 2019-12-05 04:19:09
I am confused by the terms for a long time, thinking it is good to ask out what exactly do they mean: A. syntax. B. syntax value. C. syntax object. D.s-expression E.datum (in syntax->datum) What's the difference between s-expression and symbol? What's the difference between s-expression and datum? What's the difference between (syntax, syntax values and syntax object) from s-expression? Code examples for explanation will be appreciated. "Syntax" is a type for representing source code in Racket, which is a wrapper around S-expression (see a recent blog post for details). "Syntax value" and

Analog of Python's range in Scheme

半腔热情 提交于 2019-12-05 03:40:18
How to create a list of consecutive numbers in Scheme? In Python to create a list of integers from 1 to 10 would be range(1,11) . Is there an equivalent for Scheme? mzscheme --version gives Welcome to Racket v5.2.1. Edit: Per https://stackoverflow.com/a/7144310/596361 to implement range functionality, this code is needed: #lang racket (require srfi/1) (iota 5 1) Sven Look for iota (as defined in SRFI-1). Example: (iota 10 1) gives 10 consecutive integers starting from 1 (instead of the default of 0). iota doesn't take the same arguments as range but it duplicates all the functionality -

how do i open a racket REPL with the current scope?

旧街凉风 提交于 2019-12-05 03:22:56
问题 Let's say I have a program like this: (define (foo x) (local ((define y (- x 1))) (* x y))) (foo 3) I want to be able to open a REPL between lines 3 and 4, such that I can explore (and possibly modify) the values of x and y by executing arbitrary statements. To do this in Ruby, I would take the equivalent program: def foo(x) lambda { y = x - 1 x * y }.call end puts (foo 3) And modify it by adding a call to pry to give me a nicely-scoped repl where I want it: require 'pry' def foo(x) lambda {

Writing a Scheme interpreter with FPC: Recursive data structures

感情迁移 提交于 2019-12-05 03:15:57
问题 Essentially, this is a question about recursive data structures in Pascal (FPC). As I would like to implement a Scheme interpreter like it is shown in SICP chapter 4, this question may be relevant for Schemers as well. :) S-expressions shall be represented as tagged data. So far, I have constructed a variant record, which represents numbers and pairs. Hopefully the code is readable and self-explanatory: program scheme; type TTag = (ScmFixnum, ScmPair); PScmObject = ^TScmObject; TScmObject =

Does learning one Lisp help in learning the other?

五迷三道 提交于 2019-12-05 02:07:50
Is there any synergy between learning different Lisp languages? I'm currently learning Emacs Lisp, as it is immediately useful in my daily Emacs usage, however i'm fascinated with all Lisps, so maybe someday i will learn and use others. Will learning Emacs Lisp help me, when i start digging in Common Lisp, Scheme or Clojure? In other words, will it be for me like learning a completely new language, or some notions and paradigms are common? I'm also interested in comparison of unique differences between the Lisps, which will be a problem, when i come from one Lisp to another. In How to go about

Is there a possibility of multiple statements inside a conditional statement's body?

荒凉一梦 提交于 2019-12-04 22:44:43
I'm primarily a C++ (thus an OO/imperative) programmer and I find it quite bizarre that you can only have one statement per evaluation in a conditional statement such as an if-statement in Scheme, a functional language. For example: (let ((arg1 0) (arg2 1)) (if (> arg1 arg2) arg1 arg2))) Erroneous example: (let ((arg1 0) (arg2 1)) (if (> arg1 arg2) (arg1 (display "cool")) (arg2 (display "not cool")))) gives me an error of a type "procedure application: expected procedure, given: 2; arguments were: #void" That can be solved by placing that said conditional statement into different statements

Benefits of learning scheme?

我只是一个虾纸丫 提交于 2019-12-04 22:27:15
I've just started one of my courses, as classes just began 2 weeks ago, and we are learning Scheme right now in one for I assume some reason later on, but so far from what he is teaching is basically how to write in scheme. As I sit here trying to stay awake I'm just trying to grasp why I would want to know this, and why anyone uses it. What does it excel at? Next week I plan to ask him, whats the goal to learn here other than just how to write stuff in scheme. It's a functional programming language and will do well broaden your experience. Even if you don't use it in the real world doesn't

Mauritus national flag problem

跟風遠走 提交于 2019-12-04 21:26:00
问题 I've made a solution for the Dutch national flag problem already. But this time, I want to try something more difficult: the Mauritus national flag problem - 4 colours, instead of 3. Any suggestions for an effective algorithm? Basically, The Mauritius National Flag Problem focuses on how you would be able to sort the given list of pairs based on the order of colors in the Mauritius National Flag (Red, Blue, Yellow, Green). And the numbers must be sorted in ascending order too. Scheme

ASP.NET Core[源码分析篇] - Authentication认证

╄→尐↘猪︶ㄣ 提交于 2019-12-04 21:23:51
原文: ASP.NET Core[源码分析篇] - Authentication认证   追本溯源,从使用开始     首先看一下我们通常是如何使用微软自带的认证,一般在Startup里面配置我们所需的依赖认证服务,这里通过JWT的认证方式讲解 public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(authOpt => { authOpt.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; authOpt.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(o => { o.TokenValidationParameters = new TokenValidationParameters { //配置自己所要验证的参数 }; }); }   我们来看一下源码AddAuthentication主要做了什么  public static class AuthenticationServiceCollectionExtensions { public static