Skip to content

Instantly share code, notes, and snippets.

View hovsater's full-sized avatar
🤟

Kevin Hovsäter hovsater

🤟
View GitHub Profile
@hovsater
hovsater / split.ml
Last active October 14, 2020 12:37
(*
Write a function split : int list -> int list * int list such that split l = (front, back) where
l = back @ List.rev front and the length of back and front is List.length l / 2
or List.length l / 2 + 1
*)
let split l =
let cutpoint = List.length l / 2 in
let rec aux count back = function
[] -> ([], [])
| x::xs -> if count < cutpoint
: --> LSP-elm initialize(1): {'clientInfo': {'version': '1.0.16', 'name': 'Sublime Text LSP'}, 'rootPath': '/Users/kevinsjoberg/code/PhotoGroove', 'capabilities': {'textDocument': {'signatureHelp': {'dynamicRegistration': True, 'signatureInformation': {'documentationFormat': ['markdown', 'plaintext'], 'parameterInformation': {'labelOffsetSupport': True}}}, 'colorProvider': {'dynamicRegistration': True}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'completion': {'completionItemKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}, 'dynamicRegistration': True, 'completionItem': {'snippetSupport': True, 'deprecatedSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'tagSupport': {'valueSet': [1]}}}, 'synchronization': {'didSave': True, 'dynamicRegistration': True, 'willSave': True, 'willSaveWaitUntil': True}, 'formatting': {'dynamicRegistration': True}, 'documentSymbol': {'symbolKind': {'valueSet': [1, 2, 3, 4, 5,
LSP-elm: Diagnostics were requested due to a file open or save
LSP-elm: Changed text document, going to parse it. file:///Users/kevinsjoberg/code/PhotoGroove/src/PhotoGroove.elm
:: -> LSP-elm textDocument/didOpen: {'textDocument': {'version': 0, 'uri': 'file:///Users/kevinsjoberg/code/PhotoGroove/src/PhotoGroove.elm', 'languageId': 'elm', 'text': 'module PhotoGroove exposing (main)\n\nimport Browser\nimport Html exposing (..)\nimport Html.Attributes exposing (..)\nimport Html.Events exposing (onClick)\nimport Random\n\n\nurlPrefix : String\nurlPrefix =\n "http://elm-in-action.com/"\n\n\ntype Msg\n = ClickedPhoto String\n | ClickedSize ThumbnailSize\n | ClickedSurpriseMe\n | GotRandomPhoto Photo\n\n\nview : Model -> Html Msg\nview model =\n div [ class "content" ] <|\n case model.status of\n Loaded photos selectedUrl ->\n viewLoaded photos selectedUrl model.chosenSize\n\n Loading ->\n []\n\n Errored errorMessage ->\n

Exercise

For each of the following pairs of scanf format strings, indicate whether or not the two strings are equivalent. If they're not, show how they can be distinguished.

  • "%d" versus " %d"
  • "%d-%d-%d" versus "%d -%d -%d"
  • "%f" versus "%f "
  • "%f,%f" versus "%f, %f"
#include <stdio.h>
int main(void)
{
char ch;
float sum = 0;
int word = 0, words = 0;
printf("Enter a sentence: ");

Project

Write a program that evaluates an expression:

Enter an expression: 1+2.5*3
Value of expression: 10.5

The operands in the expression are floating-point numbers; the operators

# Reconstructed via infocmp from file: /Users/kevinsjoberg/.terminfo/78/xterm-256color
xterm-256color|xterm with 256 colors,
am, bce, ccc, km, mc5i, mir, msgr, npc, xenl,
colors#256, cols#80, it#8, lines#24, pairs#0,
acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=^M,
csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C,
cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
#include <stdio.h>
#define LETTER_GROUP_SIZE 3
int main(void)
{
char ch;
printf("Enter phone number: ");
#include <stdio.h>
int main(void)
{
int i, n;
printf("This program prints a table of squares\n");
printf("Enter number of entries in table: ");
scanf("%d", &n);
@hovsater
hovsater / e06.md
Last active August 27, 2020 13:39

Exercise

For each of the following items of data, specify which one of the types char, short, int or long is the smallest one guaranteed to be large enough to store the item.

  1. Days in a month
  2. Days in a year
  3. Minutes in a day