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; |
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; } |
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) | |
{ |
type TupleToObject<T extends any[]> = { [K in keyof T as Exclude<K, keyof any[]>]: T[K] } | |
type MapTuples<T extends any[], N extends Record<keyof TupleToObject<T>, PropertyKey>> = | |
{ [K in keyof TupleToObject<T> as N[K]]: T[K] } | |
type IsNever<T> = [T] extends [never] ? true : false | |
type Numbers = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] | |
type IncMap = MapTuples<Tail<Numbers>, Numbers> | |
type Inc<T extends number> = T extends keyof IncMap ? IncMap[T] : never | |
export type Reverse<T extends any[], R extends any[] = []> = { | |
return: R | |
next: Reverse<Tail<T>, Cons<Head<T>, R>> |
#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) | |
{ |