ml_string

This commit is contained in:
VaclavT 2021-02-19 23:52:16 +01:00
parent a39e61a061
commit fa7cbad70b
5 changed files with 47 additions and 15 deletions

View File

@ -25,6 +25,7 @@ set(SOURCE
ml.cpp
ml_io.cpp
ml_date.cpp
ml_string.cpp
clib/csvparser.cpp
clib/sslclient.cpp
clib/json11.cpp ml_date.h ml_date.cpp)
@ -32,3 +33,7 @@ set(SOURCE
add_executable(${PROJECT_NAME} ${SOURCE})
target_link_libraries(${PROJECT_NAME} stdc++ m ssl crypto)
INSTALL(TARGETS ml
CONFIGURATIONS Release
DESTINATION /usr/local/bin/)

View File

@ -1,11 +1,12 @@
### TODO
- date support
- decode-universal-time
- logical operators
- print-table
- download 1 year of data from api.nasdaq.com into test dir
- support for including lisp libs at startup from dir
- documentation
- rename data.csv and add more tickers
- logical operators
- add url of source/inspiration to clib/*.cpp
- support for including lisp libs
- add stdtest - to test every functionality
- rename ivaluize
- add benchmark
@ -23,13 +24,14 @@
- string functions
- name it here
- regexp functions
- date support
- decode-universal-time
- anv function
- add hash datatype
- add support for nil
- conversion functions like parse-integer
- list function nth
- in test.lisp some explaining prints
- rename data.csv and add more tickers
#### Performance
- push_back - repeatedly without reserving size
@ -43,6 +45,7 @@ time ./build/ml -c '(include "../example.lisp") (print (fact 1000))'
```
### Links
https://hyperpolyglot.org/lisp
https://www.tutorialspoint.com/lisp/index.htm
https://github.com/adam-mcdaniel/wisp
@ -61,4 +64,9 @@ https://stackoverflow.com/questions/25896916/parse-http-headers-in-c
#### read stdout and stderr from popen
https://stackoverflow.com/questions/478898/how-do-i-execute-a-command-and-get-the-output-of-the-command-within-c-using-po
https://stackoverflow.com/questions/478898/how-do-i-execute-a-command-and-get-the-output-of-the-command-within-c-using-po
#### VPS providers
https://www.skysilk.com/cloud/pricing/#classId=Standard&section=2
https://contabo.com/en/
https://www.hetzner.com/de/

9
ml.cpp
View File

@ -2,6 +2,7 @@
#include "ml.h"
#include "ml_io.h"
#include "ml_date.h"
#include "ml_string.h"
#include "csvparser.h"
#include "sslclient.h"
@ -49,14 +50,6 @@
// Convert an object to a string using a string stream conveniently
#define to_string(x) static_cast<std::ostringstream>((std::ostringstream() << std::dec << x )).str()
// Replace a substring with a replacement string in a source string
void replace_substring(std::string &src, const std::string &substr, const std::string &replacement) {
size_t i = 0;
for (i = src.find(substr, i); i != std::string::npos; i = src.find(substr, i)) {
src.replace(i, substr.size(), replacement);
i += replacement.size();
}
}
// Is this character a valid lisp symbol character
bool is_symbol(char ch) {

14
ml_string.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "ml_string.h"
// Replace a substring with a replacement string in a source string
void replace_substring(std::string &src, const std::string &substr, const std::string &replacement) {
size_t i = 0;
for (i = src.find(substr, i); i != std::string::npos; i = src.find(substr, i)) {
src.replace(i, substr.size(), replacement);
i += replacement.size();
}
}

12
ml_string.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include "ml.h"
#include <string>
// Replace a substring with a replacement string in a source string
void replace_substring(std::string &src, const std::string &substr, const std::string &replacement);