我在项目目录中有一个.txt文件,我用数据填充.
目录结构如下:
/Users/asd/ClionProjects/ProjectWithTemplates/
main.cpp
cmake
twoday.txt
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
#include <iostream>
#include <array>
#include <cmath>
#include <fstream>
using namespace std;
/* print array prototype */
template <size_t N>
void printArray(const array<double , N> & arr);
/* mean function prototype */
template <size_t N>
double meanArray(const array<double , N> & arr);
/* standard deviation prototype */
template <size_t N>
double sDeviation(const array<double , N> & arr);
int main() {
string date1;
string date2;
array<double, 24> day1Temps;
array<double, 24> day2Temps;
array<double, 3> testarr = …
Run Code Online (Sandbox Code Playgroud) 如果我有数据类型识别和人,我该如何使用它们?
type identification = Name of string
| SS of int * int;;
type person = Personal_info of identification;;
Run Code Online (Sandbox Code Playgroud)
如何制作具有标识的人物类型?我如何构造一个包含这些类型的变量..?
像这样:
person1 = Personal_info (Name = "Cody") (SS = (231,4534));;
val person1 : person = .....
Run Code Online (Sandbox Code Playgroud) 来自Real World OCaml的示例第60页
List.map ~f:((+) 3) [4;5;6;];;
Error: The function applied to this argument has type 'a list -> 'b list
This argument cannot be applied with label ~f
Run Code Online (Sandbox Code Playgroud)
来自HTML托管版RWO的相同示例
List.map ~f:((+) 3) [4;5;6];;
- : int list = [7; 8; 9]
Error: The function applied to this argument has type 'a list -> 'b list
This argument cannot be applied with label ~f
Run Code Online (Sandbox Code Playgroud)
显然有些重大改变了吗?为什么这些例子不起作用?有更好的书可供学习吗?
这种语言很棒,我想尽我所能,但资源很少.