Random Posts

{"content":{"id":1578,"title":"Baa","body":"\u003cimg src=\"/uploads/4e0.png\"\u003e","publication_date":"2020-09-27T00:00:00.000Z","created_at":"2020-08-16T18:13:07.000Z","updated_at":"2020-08-16T18:13:07.000Z","user_id":1,"rating":null},"tags":"\u003ca class=\"changeable-title\" href=\"/q?tag=pictures\"\u003epictures\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=animals\"\u003eanimals\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=old_comics\"\u003eold_comics\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=red\"\u003ered\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=brown\"\u003ebrown\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=white\"\u003ewhite\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=movies\"\u003emovies\u003c/a\u003e"}

Baa

{"content":{"id":103,"title":"Avengers: Age Of Ultron (2015)","body":"\u003cp\u003eThere's a lot of good, weird stuff in this movie, but I just can't get past the robot lips. They move like flesh, but look like they are made of solid metal. But not in a cool way, in a panicked last-minute decision kind of way.\u003c/p\u003e","publication_date":"2018-06-20T06:00:00.000Z","created_at":"2018-06-13T21:29:36.000Z","updated_at":"2018-09-14T19:17:38.000Z","user_id":1,"rating":4},"tags":"\u003ca class=\"changeable-title\" href=\"/q?tag=movies\"\u003emovies\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=reviews\"\u003ereviews\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=lips\"\u003elips\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=bad_weird\"\u003ebad_weird\u003c/a\u003e"}

Avengers: Age Of Ultron (2015)

There's a lot of good, weird stuff in this movie, but I just can't get past the robot lips. They move like flesh, but look like they are made of solid metal. But not in a cool way, in a panicked last-minute decision kind of way.

{"content":{"id":793,"title":"The Qianlong Emperor","body":"\u003cimg src=\"/uploads/2a2.jpg\" class=\"card-image not-tall\"\u003e","publication_date":"2019-07-13T00:00:00.000Z","created_at":"2019-06-18T03:33:10.000Z","updated_at":"2019-06-18T03:33:10.000Z","user_id":1,"rating":null},"tags":"\u003ca class=\"changeable-title\" href=\"/q?tag=china\"\u003echina\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=qing\"\u003eqing\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=eighteenth_century\"\u003eeighteenth_century\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=painting\"\u003epainting\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=portraits\"\u003eportraits\u003c/a\u003e"}

The Qianlong Emperor

{"content":{"id":482,"title":"Julius Caesar","body":"\u003cimg src=\"/uploads/18b.jpg\" class=\"card-image\"\u003e","publication_date":"2019-01-29T00:00:00.000Z","created_at":"2019-01-22T00:01:11.000Z","updated_at":"2019-01-22T00:01:11.000Z","user_id":1,"rating":null},"tags":"\u003ca class=\"changeable-title\" href=\"/q?tag=pictures\"\u003epictures\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=rome\"\u003erome\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=ancient\"\u003eancient\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=animals\"\u003eanimals\u003c/a\u003e"}

Julius Caesar

{"content":{"id":8,"title":"'Build Your Own Lisp' Solutions: 3.1","body":"\u003cp\u003e\u003cb\u003eQ:\u003c/b\u003e Use a for loop to print out Hello World! five times.\u003c/p\u003e\r\n\u003cp\u003e\u003cb\u003eA:\u003c/b\u003e\u003c/p\u003e\r\n\u003cpre\u003e\u003ccode class=\"c++\"\u003e#include \u0026lt;stdio.h\u0026gt;\r\n\r\nint main(void) {\r\n int i;\r\n\r\n for (i = 0; i \u003c 5; i++) {\r\n printf(\"Hello World!\\n\");\r\n }\r\n\r\n return 0;\r\n}\r\n\u003c/code\u003e\u003c/pre\u003e\r\n\r\n\u003cpre\u003e\u003ccode class=\"c++\"\u003eHello world!\r\nHello world!\r\nHello world!\r\nHello world!\r\nHello world!\r\n\u003c/code\u003e\u003c/pre\u003e","publication_date":"2018-05-14T00:00:00.000Z","created_at":"2018-05-09T22:18:25.000Z","updated_at":"2018-06-18T17:30:03.000Z","user_id":1,"rating":null},"tags":"\u003ca class=\"changeable-title\" href=\"/q?tag=c\"\u003ec\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=lisp\"\u003elisp\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=build_your_own_lisp\"\u003ebuild_your_own_lisp\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=answers\"\u003eanswers\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=programming\"\u003eprogramming\u003c/a\u003e"}

'Build Your Own Lisp' Solutions: 3.1

Q: Use a for loop to print out Hello World! five times.

A:

#include <stdio.h>

int main(void) {
  int i;

  for (i = 0; i < 5; i++) {
    printf("Hello World!\n");
  }

  return 0;
}
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
{"content":{"id":41,"title":"Shawshank Redemption (1994)","body":"\u003cp\u003eIt truly was \u003ci\u003e\u003cb\u003ea Shawshank Redemption\u003c/b\u003e\u003c/i\u003e.\u003c/p\u003e","publication_date":"2018-06-04T00:00:00.000Z","created_at":"2018-05-30T21:10:28.000Z","updated_at":"2018-06-18T16:39:18.000Z","user_id":1,"rating":4},"tags":"\u003ca class=\"changeable-title\" href=\"/q?tag=tom_hanks\"\u003etom_hanks\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=movies\"\u003emovies\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=reviews\"\u003ereviews\u003c/a\u003e"}

Shawshank Redemption (1994)

It truly was a Shawshank Redemption.

{"content":{"id":109,"title":"SICP Solutions - 1.6","body":"\u003cbr\u003e\r\n\u003cp\u003e\u003cb\u003eQ:\u003c/b\u003e Alyssa P. Hacker doesn't see why if needs to be provided as a special form. ``Why can't I just define it as an ordinary procedure in terms of cond?'' she asks. Alyssa's friend Eva Lu Ator claims this can indeed be done, and she defines a new version of if: \u003c/p\u003e\r\n\u003cpre\u003e\u003ccode class=\"lisp\"\u003e(define (new-if predicate then-clause else-clause)\r\n (cond (predicate then-clause)\r\n (else else-clause)))\r\n\u003c/code\u003e\u003c/pre\u003e\r\n\u003cp\u003e\r\nEva demonstrates the program for Alyssa:\r\n\u003c/p\u003e\r\n\u003cpre\u003e\u003ccode class=\"lisp\"\u003e(new-if (= 2 3) 0 5)\r\n5\r\n\r\n(new-if (= 1 1) 0 5)\r\n0\r\n\u003c/code\u003e\u003c/pre\u003e\r\n\u003cp\u003eDelighted, Alyssa uses new-if to rewrite the square-root program:\u003c/p\u003e\r\n\u003cpre\u003e\u003ccode class=\"lisp\"\u003e(define (sqrt-iter guess x)\r\n (new-if (good-enough? guess x)\r\n guess\r\n (sqrt-iter (improve guess x)\r\n x)))\r\n\u003c/code\u003e\u003c/pre\u003e\r\n\u003cp\u003eWhat happens when Alyssa attempts to use this to compute square roots? Explain.\u003c/p\u003e\r\n\u003cbr\u003e\r\n\u003cp\u003e \u003cb\u003eA:\u003c/b\u003e The program hangs forever. This is a similar issue to the \u003ca href=\"https://sananab.ca/posts/106\" target=\"_blank\"\u003elast problem\u003c/a\u003e. Because of application order, it will continuously evaluate sqrt-iter in an infinite loop. Normal 'if' in Scheme is a special procedure built into the language and does not have that behaviour.\u003c/p\u003e","publication_date":"2018-06-23T03:00:00.000Z","created_at":"2018-06-17T17:53:06.000Z","updated_at":"2018-06-22T14:14:07.000Z","user_id":1,"rating":null},"tags":"\u003ca class=\"changeable-title\" href=\"/q?tag=sicp\"\u003esicp\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=programming\"\u003eprogramming\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=answers\"\u003eanswers\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=lisp\"\u003elisp\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=scheme\"\u003escheme\u003c/a\u003e"}

SICP Solutions - 1.6


Q: Alyssa P. Hacker doesn't see why if needs to be provided as a special form. ``Why can't I just define it as an ordinary procedure in terms of cond?'' she asks. Alyssa's friend Eva Lu Ator claims this can indeed be done, and she defines a new version of if:

(define (new-if predicate then-clause else-clause)
  (cond (predicate then-clause)
        (else else-clause)))

Eva demonstrates the program for Alyssa:

(new-if (= 2 3) 0 5)
5

(new-if (= 1 1) 0 5)
0

Delighted, Alyssa uses new-if to rewrite the square-root program:

(define (sqrt-iter guess x)
  (new-if (good-enough? guess x)
          guess
          (sqrt-iter (improve guess x)
                     x)))

What happens when Alyssa attempts to use this to compute square roots? Explain.


A: The program hangs forever. This is a similar issue to the last problem. Because of application order, it will continuously evaluate sqrt-iter in an infinite loop. Normal 'if' in Scheme is a special procedure built into the language and does not have that behaviour.

{"content":{"id":1337,"title":"Daily Links","body":"\u003cp\u003e\r\nMore classic \u003ca href=\"https://joshreads.com/2004/09/for-the-love-of-god-blaze/\"\u003eJosh Reads\u003c/a\u003e.\r\n\u003c/p\u003e","publication_date":"2020-04-29T12:00:00.000Z","created_at":"2020-04-24T03:59:08.000Z","updated_at":"2020-04-24T03:59:13.000Z","user_id":1,"rating":null},"tags":"\u003ca class=\"changeable-title\" href=\"/q?tag=comics\"\u003ecomics\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=daily_links\"\u003edaily_links\u003c/a\u003e"}

Daily Links

More classic Josh Reads.

{"content":{"id":336,"title":"Akihabara, Tokyo, By Series-Of-Tubes","body":"\u003cimg src=\"/uploads/10c.jpg\" class=\"card-image\"\u003e","publication_date":"2018-10-31T00:00:00.000Z","created_at":"2018-10-24T01:41:51.000Z","updated_at":"2018-10-24T01:41:51.000Z","user_id":1,"rating":null},"tags":"\u003ca class=\"changeable-title\" href=\"/q?tag=japan\"\u003ejapan\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=pictures\"\u003epictures\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=anime\"\u003eanime\u003c/a\u003e \u003ca class=\"changeable-title\" href=\"/q?tag=hype\"\u003ehype\u003c/a\u003e"}

Akihabara, Tokyo, By Series-Of-Tubes