soegaard2
2020-6-10 09:09:11

Poor Intel: First AMD and now Apple. It is going to be an interesting race. I hope ARM chips will bring more cores (at comparable prices).


soegaard2
2020-6-10 10:15:44

FWIW I see that in http://www.netlib.org/blas/cblas.h they use void * to pass an array of complex floating points. Not sure if this is a general C thing - or due to an older Fortran convention.


dcmicoltacespedes
2020-6-10 13:14:06

good morning, how are you. I have problems with this exercise. I want separate this list in parts most littles. -> ((list 1 2 3 4 5 6 7 8 9 10)2) ->(list 1 2)(list 3 4)(list 5 6)(list 7 8)(list 9 10).

I’m make this code: (define (count list) (cond [(empty? list) 0] [else (+ 1 (count (rest list)))] ) ) (define (list-divide list element) (cond [(empty? list) "U can't divide the list"] [(= element count) (cons (first list)(first(rest list)))] [else "no se puede dividir"] ) ) (list-divide (length (list 1 2 3 4 5 6 7 8 9 10)) 2) I don’t know how I do, to separate the list, in lists with two elements. thanks.


dcmicoltacespedes
2020-6-10 14:08:35

Is showing me this error: <: contract violation expected: real? given: #<procedure:count> argument position: 2nd other arguments...: 2


soegaard2
2020-6-10 14:13:25

This is a problem: [(= element count) . Here count is a function which needs to be called (count list).


dcmicoltacespedes
2020-6-10 14:18:42

Oh thanks. Now, Is showing me this error: rest: contract violation expected: (and/c list? (not/c empty?)) given: 10 :worried:


soegaard2
2020-6-10 14:19:31

Which expression?


soegaard2
2020-6-10 14:20:27

Actually it must be: (list-divide (length (list 1 2 3 4 5 6 7 8 9 10)) 2) Since list-divide expects a list, you can take the length first.


dcmicoltacespedes
2020-6-10 14:21:58

(define (count list) (cond [(empty? list) 0] [else (+ 1 (count (rest list)))] ) ) (define (list-divide list element) (cond [(empty? list) "U can't divide the list"] [(= element (count list)) (cons (first list)(first(rest list)))] [else "no se puede dividir"] ) ) (list-divide (length (list 1 2 3 4 5 6 7 8 9 10)) 2)


soegaard2
2020-6-10 14:26:06

Remove the call to length in (list-divide (length (list 1 2 3 4 5 6 7 8 9 10)) 2).


dcmicoltacespedes
2020-6-10 14:33:51

done, but the list is not divided. It is assumed that according to the number you put, the list is divided with that number of elementsSomething like some kind of loop?


soegaard2
2020-6-10 14:36:05

So ‘element’ is the number of elements in each of the lists?


dcmicoltacespedes
2020-6-10 14:43:06

yes, that should do element :sweat_smile:


soegaard2
2020-6-10 14:45:47

Consider making a simpler, helper functions first: (define (take lst k) ...) Given a list lst it returns the first k elements.

Then write (define (skip lst k) ...) which given a list list removes the first k elements.

Then use take and skip to write list-divide.


soegaard2
2020-6-10 15:30:31

Consider the following: (define _flomat (_cpointer 'flomat)) (define p (cast (malloc 1 _double 'atomic) _pointer _flomat)) (ptr-ref p _double) The result is 2.1751677484121e–314 However I was expecting to see 0.0 since malloc zeros out the returned memory.

And to make sure 0.0 is represented as zero-bytes I tried this: (real->floating-point-bytes 0.0 8) which gave: #"\0\0\0\0\0\0\0\0".


soegaard2
2020-6-10 15:32:23

This is in Racket BC 7.5. Just tested in Racket CS 7.7 and here it works.


soegaard2
2020-6-10 15:33:02

In BC 7.7 it still gives 2.182457299669e–314


massung
2020-6-10 15:34:34

Welcome to DrRacket, version 7.7 [3m]. Language: racket [custom]; memory limit: 256 MB. 4.743030200076e–322


massung
2020-6-10 15:34:54

just for reference on my machine


massung
2020-6-10 15:35:05

definitely not zeroed out :slightly_smiling_face:


samth
2020-6-10 15:36:01

I don’t think you can rely on malloc producing all–0 memory


soegaard2
2020-6-10 15:37:44

The docs says this:


soegaard2
2020-6-10 15:38:32

But you are right, it must malloc returning non-zeros.


mflatt
2020-6-10 16:01:01

It looks like the documentation is incorrect, and Racket CS zeros memory because I followed the documentation. I think probably the documentation and Racket CS should change.


soegaard2
2020-6-10 16:11:14

Makes sense the user can decide to zero or not.


laurent.orseau
2020-6-10 16:22:43

Welcome to DrRacket, version 4.743030200076e–322 [3m]


dcmicoltacespedes
2020-6-10 16:42:21

why this function (remq ’(2) (list’ (1) ’(2)’ (3))) return ’((1) (2) (3)). Shouldn’t I return ’((1) (3))?


massung
2020-6-10 16:46:26

Doesn’t remq use eq? for comparison? You want remove , which uses equal? for the comparison.


dcmicoltacespedes
2020-6-10 17:26:31

I want to know its logic, is that this example appears in the documentation and is different from the others and I want to know why. Here: <file:///C:/Program%20Files/Racket/doc/reference/pairs.html?q=list-tail#%28def._%28%28lib._racket%2Fprivate%2Flist..rkt%29._remq%29%29>


sorawee
2020-6-10 17:35:47

@dcmicoltacespedes I think @massung’s explanation is pretty clear. Is there anything that you are still confused?


sorawee
2020-6-10 17:36:13

Do you know how eq? works, and how it is different from equal??


massung
2020-6-10 17:41:28

(eq? '(a) '(a)) ;=&gt; #f (eqv? '(a) '(a)) ;=&gt; #f (equal? '(a) '(a)) ;=&gt; #t


soegaard2
2020-6-10 20:48:16

I want to list and “def” some identifiers in Scribble. The result of defform* looks okay. However it only defs the first identifier. Is there an alternative that gives a similar compact output (ideally without the parentheses around the identifiers?


jaz
2020-6-10 20:58:54

A deftogether around a bunch of defidform s (or defthings), maybe?


soegaard2
2020-6-10 21:01:10

Deftogether looks right.


notjack
2020-6-10 23:26:54

tip: use [[ with deftogether to get nice formatting and indentation from DrRacket

@deftogether[[ @defthing[foo thing?] @defthing[bar thing?] @defthing[baz thing?]]]{ ...}