Comments (5)
Wouldn't you build those out of LISP itself, adding to your "prelude", don't think you need to bake those into the builtin's (though I'm sure it is possible).
from buildyourownlisp.
Ah.. I was try.. but without any progress. That is why I need help.. example or similar..
But, your post may help.. i think.
I will try something as you wrote.
(fun {do & l} {
if (== l nil)
{nil}
{last l}
})
that's smell as repeat() function eg. repeat number of times(function or calculation)
Problem is harder.. You see.. repeat function need to send output after every loop. while(), for() doing same...
whatever I wrote whenever my new function send output they broke self.
Your above function is OK.. they send out only last l .. but loop functions send's output after every loop.
how to wrote to resume on next loop without stopping self?
Sorry I am not expert in english. , I hope You will understand what is a problem.
from buildyourownlisp.
I'd query why you want a for/while/repeat, not being obtuse, but in general, I'd stick to map, fold and reduce functions for functional programming. e.g. in Scala, I don't think I've ever used a while loop....
That said, I think it is fairly fundamental that you don't (author can correct me if I'm wrong) implement those things in the C, rather the C is effectively a simple extended lambda-calculus engine of sorts, and the prelude should implement the higher level constructs. The builtin is I think supposed to be just enough for you to build a prelude in your language.
from buildyourownlisp.
I try to put these code on higher level...
I am game maker programmer.. A expert for older version of gamemaker from gm 4 to gm 8.1..
So, this can be interested 'cose GM studio 1 and 2 was very veeery slow while compile code.
Older version was been written in Python, now that is all ported to C++, and it's NOT GOOD. Too slow... not game.. compiling. For me as programmer that is horror...
To be short,
When you create eg sky with stars you will need repeat, or while, or similar instead to write codes for every star on sky.
I was import SDL codes here, and they works... Nothing big.. about 10-15 commands, but I was stop when I realise that I can't to do many things who are depend from loops.
eg, checking collision, positions etc,
That is not cruicial only for games..
So, if IS possible, please help me to make loop functions, built in, or external...
tnx in advance.
from buildyourownlisp.
Ok.. I was make built-in function REPEAT
I need While, for, etc etc loop functions
lval* builtin_repeat( lenv* e, lval* v) {
LASSERT_NUM("repeat", v, 2);
LASSERT_TYPE("repeat", v, 0, LVAL_NUM);
LASSERT_TYPE("repeat", v, 1, LVAL_QEXPR);
v->cell[1]->type = LVAL_SEXPR;
int broj= (int)v->cell[0]->num;
lval* res;
lval* x;
lval* y;
int i = 0;
lval* l[broj];
while (broj > i){
y= lval_copy(v);
res= lval_pop( y, 1);
x = lval_eval(e, res);
l[i] = x;
lval_println(x);
x=NULL;
y=NULL;
res=NULL;
i++;
}
lval_del(v);
return l[1];
}
USAGe
repeat 5{ print "aa"}
repeat 5{100}
repeat 10 { + 2 3}
etc etc
and YES.. I was make and function for random number.
from buildyourownlisp.
Related Issues (20)
- Errors with MPC HOT 1
- PCQ Rename
- Wrong name of source.tar.gz
- Segmentation fault chapter 6 mpc
- Average expression for extra points HOT 1
- [noob] can I learn this project and `antlr` at the same time
- Segfault being caused by mpc_parse_run HOT 4
- A link in chapter two doesn't exist anymore. HOT 4
- Suggesting msys2 instead of MinGW In Ch2 installation compiler section
- GNU Readline 8.1 does not use history.h anymore
- Not Isue, help with decimal numbers HOT 2
- Function defintions HOT 2
- Syntax for Lambda expressions
- question on the need for Q expression? HOT 3
- How can we implement macros HOT 1
- Print statement not working while evaluating file HOT 3
- it's not work until I remove eval_op() and eval(). It's hard to follow
- What is the best way to include stdlib into binary? HOT 2
- Doesn't properly handle a single negative number as the input in `evaluation.c`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buildyourownlisp.