Criar um app console SEM persistencia (nao precisa de banco de dados)
Um programa que receberá linhas de um json
como entrada stdin
e deverá fornecer uma saída com a conta resultante para cada uma das operações em json
open System.Net.Sockets | |
open System.Net | |
open System | |
open System.Text | |
open System.Threading | |
let localPort = 8800 | |
let serverPort = 8888 | |
let serverUri = Uri("http://localhost") |
using System.Text.Json; | |
using System.Text.Json.Serialization; | |
/// <summary> | |
/// Json converter for DateTime forcing local time | |
/// </summary> | |
public sealed class DateTimeForceLocalJsonConverter : JsonConverter<DateTime> | |
{ | |
readonly TimeSpan offset; |
using System; | |
using System.Runtime.CompilerServices; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Text; | |
using System.Linq; | |
ValueList<int> nums = new(); | |
nums.Add(10); | |
nums.Add(20); |
readonly struct MemoryBuffer<T> : IDisposable | |
{ | |
readonly bool clearArray; | |
readonly T[] array; | |
public int Length { get; } | |
public Memory<T> Memory { get; } | |
internal MemoryBuffer(int size, bool clearArray = false) | |
{ |
public sealed class CircularBuffer<T>(int capacity = 64) : IReadOnlyList<T> | |
where T : notnull | |
{ | |
readonly T[] elements = new T[capacity]; | |
int head, tail; | |
public int Capacity => elements.Length; | |
public int Length { get; private set; } |
#r "nuget: FSharp.Data" | |
#r "nuget: Humanizer.Core" | |
#r "nuget: EluciusFTW.SpectreCoff" | |
open FSharp.Data | |
open SpectreCoff | |
open Humanizer | |
open System | |
open System.Globalization | |
open Spectre.Console |
using System; | |
using System.Linq; | |
using System.Collections.Generic; | |
using System.Collections; | |
using System.Text.Json; | |
using static System.Console; | |
Document[] docs = | |
{ | |
new( |
using System.Diagnostics; | |
using System.Net; | |
using System.Net.Sockets; | |
using static System.Text.Encoding; | |
using static System.Console; | |
const int MaxUdpByteSize = 65527; | |
static Socket CreateSocket(int port) | |
{ |
module Result = | |
let join x1 x2 = | |
match x1, x2 with | |
| Ok x1res, Ok x2res -> Ok(x1res, x2res) | |
| Error e1, Error e2 -> Error(e1 @ e2) | |
| Error e, _ | |
| _, Error e -> Error e | |
type ResultBuilder() = |